下面是file_get_contents和curl两个函数同样功能的不同写法
file_get_contents函数的使用示例:
复制代码 代码如下:
< ?php
$file_contents = file_get_contents(‘http://www.jb51.net');
echo $file_contents;
?>
换成curl函数的使用示例:
复制代码 代码如下:
< ?php
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, curlopt_url, ‘http://www.jb51.net');
curl_setopt ($ch, curlopt_returntransfer, 1);
curl_setopt ($ch, curlopt_connecttimeout, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
echo $file_contents;
?>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!