When using file_get_contents to retrieve data, php reports the following error: PHP Warning: file_get_contents failed to open stream: no suitable wrapper cocould be found.
Finally, curl is used to obtain data!
Baidu today! The solution is found! Copy it first!
System: centos 6.5
In the error log, the error reported by php is
Warning: file_get_contents () [function. file-get-contents]: http: // wrapper is disabled in the server configuration by allow_url_fopen = 0
Failed to open stream: no suitable wrapper cocould be found
This warning indicates that the server blocks access to remote files and modifies php. ini.
Set
Allow_url_fopen = Off
Allow_url_include = Off
Change
Allow_url_fopen = On
Allow_url_include = On
Restart php-fpm or the web service.
If the problem persists
Solution in windows:
C: \ windows \ php. ini
Extension = php_openssl.dll remove the previous one and restart the iis service.
Solution in linux:
/Etc/php. ini
Extension = php_openssl.dll remove the previous one and restart the apache service.
If the problem above does not solve my problem, we can test it as follows.
$ Context = stream_context_create (array ('http '=> array ('ignore _ errors' => true )));
$ Contents = file_get_contents ($ url, FALSE, $ context );
Ignore errors when requests are allowed. Can solve the warning information