Home > Backend Development > PHP Tutorial > PHP file_get_contents函数报错怎么办

PHP file_get_contents函数报错怎么办

PHPz
Release: 2020-06-24 10:32:25
Original
2241 people have browsed it

PHP file_get_contents函数报错怎么办

PHP file_get_contents函数报错问题

file_get_contents这个php函数抓取数据常见错误解决方法

方法一:找到php.ini文件,修改如下:

1、找到extension=php_openssl.dll这一行,去掉前面的‘;’

2、找到allow_url_include = Off 这一行,将Off改为 On,然后重启服务器。

方法二:同样,再php.ini中找到user_agent="PHP"这一行,去掉前面的‘;’,重启服务器。如果依然解决不了,那么将这一行替换为:user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)",重启服务器。

方法三:在你的代码下添加如下代码:

$result  = file_get_contents($reqData['formUrl'], false, $context);
$results = iconv("utf-8", "utf-8//IGNORE",$result);
Copy after login

更多相关技术文章,请访问PHP中文网

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template