首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

php调用远路url的四种方法

2012-12-18 
php调用远程url的四种方法1、 用file_get_contents 以get方式获取内容示例:4、使用curl库,使用 curl库之前,

php调用远程url的四种方法
1、 用file_get_contents 以get方式获取内容
示例:


4、使用curl库,使用 curl库之前,需先确认有打开curl扩展
$ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); echo $file_contents;

热点排行