首頁 > php教程 > PHP源码 > file_get_contents和curl

file_get_contents和curl

PHP中文网
發布: 2016-05-25 17:07:06
原創
1056 人瀏覽過

php代码

< ?php
function vita_get_url_content($url) {
if(function_exists(file_get_contents)) {
$file_contents = file_get_contents($url);
} else {
$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);
}
return $file_contents;
}
?>
登入後複製

相關標籤:
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
最新問題
php - file_get_contents($url); 輸入json
來自於 1970-01-01 08:00:00
0
0
0
PHP - 瀏覽器和file_get_contents回傳結果不一致
來自於 1970-01-01 08:00:00
0
0
0
PHP 中同時呼叫多個 API
來自於 1970-01-01 08:00:00
0
0
0
如何在 php curl 中設定布林值 true
來自於 1970-01-01 08:00:00
0
0
0
在php中透過CURL發送base64編碼的檔案和JSON
來自於 1970-01-01 08:00:00
0
0
0
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板