PHP stream_context_create()函数的使用示例
2015-05-12 00:00
781 查看
stream_context_create()函数是用来 创建打开文件的上下文件选项 ,用于fopen(),file_get_contents()等过程的超时设置、代理服务器、请求方式、头信息设置的特殊过程。
比如说,上篇php教程中gd库实现下载网页所有图片中,第10行:
利用了stream_context_create()设置代理服务器:
利用了stream_context_create()设置超时时间:
比如说,上篇php教程中gd库实现下载网页所有图片中,第10行:
利用了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('http://www.jb51.net', false, $context);
相关文章推荐
- PHP stream_context_create()函数的使用示例
- PHP实用函数手册:stream_context_create()模拟POST/GET
- PHP实用函数:stream_context_create()模拟POST/GET
- PHP使用stream_context_create()模拟POST/GET请求的方法
- PHP使用stream_context_create()模拟POST/GET请求的方法
- PHP register_shutdown_function()函数的使用示例
- 【转载】PHP使用empty检查函数返回结果时报Fatal error: Can't use function return value in write context的问题
- PHP register_shutdown_function()函数的使用示例
- PHP register_shutdown_function()函数的使用示例
- PHP 使用header函数设置HTTP头的示例方法 表头
- stream_context_create() 函数
- PHP中使用数组指针函数操作数组示例
- 使用stream_context_create远程上传文件
- PHP扩展之图像处理2——Gmagick库使用示例及相关类和函数
- PHP扩展之文本处理(三)——POSIX正则表达式函数及使用示例
- PHP操作文件的一些基本函数使用示例
- PHP操作文件的一些基本函数使用示例
- PHP中使用数组指针函数操作数组示例
- PHP中使用数组指针函数操作数组示例
- PHP 使用header函数设置HTTP头的示例方法 表头 (xlsx下载)