<?php    $url="武则天秘史";     
    $vod['vod_name']=urlencode($url);;    
    $contents_url_one=" http://www.tvmao.com/query.jsp?keys=".$vod['vod_name'];
    $contents_url_html=ff_file_get_contents($contents_url_one);
    print_r($contents_url_html);
function ff_file_get_contents($url){
for($i=0;$i<3;$i++){
$content = @file_get_contents($url);
if($content) break;
}
if($content){
return $content;
}
if(function_exists('curl_init')){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
$content = curl_exec($ch);
curl_close($ch);
if($content){
return $content;
}
}
return false;
}
?>早在代码,在我这儿执行,是空的,啥都没有,
但是,给网上一个朋友运行一下,又有HTML代码。
现在我很苦恼。

解决方案 »

  1.   

    if(function_exists('curl_init')){

    加个 else{}试试, 是不是你本地没有开CURL
      

  2.   

    拜托 你$url赋的什么值?有没有搞错啊 老大。那是放链接的参数
      

  3.   


    $contents_url_one=" http://www.tvmao.com/query.jsp?keys=".$vod['vod_name'];
    =>
    $contents_url_one="http://www.tvmao.com/query.jsp?keys=".$vod['vod_name'];地址开头处的空格
      

  4.   

    应该是url地址问题,你再调用之前
    echo $url;看下输出的地址你能接受不