php curl请求 和 打印日志

//打印日志(参数:url为路径+文件名+后缀,data为日志所有内容)

function print_log($url,$data){
    $file = fopen($url,"a");  
    fwrite($file,date('Y-m-d H:i:s').':'.$data."\r\n");  
    fclose($file);    
}
function curl_post($url,$data){
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);//超时时间(秒)
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
    $output = curl_exec($ch);
    curl_close($ch);    
    return $output; 
}

你可能感兴趣的:(封装方法,php)