《PHP編程:PHP stream_context_create()函數的使用示例》要點:
本文介紹了PHP編程:PHP stream_context_create()函數的使用示例,希望對您有用。如果有疑問,可以聯系我們。
PHP編程stream_context_create()函數是用來 創建打開文件的上下文件選項 ,用于fopen(),file_get_contents()等過程的超時設置、代理服務器、哀求方式、頭信息設置的特殊過程.
PHP編程好比說,上篇php教程中gd庫實現下載網頁所有圖片中,第10行:
PHP編程利用了stream_context_create()設置代理經銷服務器:
代碼如下:
//設置代理經銷服務器
$opts = array('http'=>array('request_fulluri'=>true));
$context = stream_context_create($opts);
$content = file_get_contents($url,false,$context);
利用了stream_context_create()設置超時時間:
代碼如下:
?$opts = array(
??? 'http'=>array(
??? 'method'=>"GET",
??? 'timeout'=>60,
? )
);
$context = stream_context_create($opts);
$html =file_get_contents('', false, $context);
歡迎參與《PHP編程:PHP stream_context_create()函數的使用示例》討論,分享您的想法,維易PHP學院為您提供專業教程。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/10893.html