直接echo file_get_contents('http://fitness.39.net/food/');
显示:
Warning: file_get_contents(http://fitness.39.net/food/) [function.file-get-contents]: failed to open stream: HTTP request failed!
怀疑是服务器验证了的浏览器UA,于是在php.ini中设置:
allow_url_fopen =on
user_agent=”Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)”
重启apache,然后还是成功的失败了,依旧:
Warning: file_get_contents(http://fitness.39.net/food/) [function.file-get-contents]: failed to open stream: HTTP request failed!
求高手解答
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证0级讲师