读取远程文件的几种方法,做采集的第一步就是读取远程文件…
1.file_get_contents
2.curl
3.fopen->fread->fclose
ps1.使用file_get_contents和fopen必须空间开启allow_url_fopen。方法:编辑php.ini,设置 allow_url_fopen = on,allow_url_fopen关闭时fopen和file_get_contents都不能打开远程文件。
ps2.使用curl必须空间开启curl。方法:win下修改php.ini,将extension=php_curl.dll前面的分号去掉,而且需要拷贝ssleay32.dll和libeay32.dll到c:\windows\system32下;linux下要安装curl扩展。
建议打开url时使用file_get_contents()方法,可优化打开速度
