This article uses two methods to solve the problem that the file_get_contents function in PHP fails to capture the https address. For more information, see
This article uses two methods to solve the problem that the file_get_contents function in PHP fails to capture the https address. For more information, see
Method 1:
In php, When you capture an https website, the following error message is displayed:
Warning: file_get_contents () [function. file-get-contents]: failed to open stream: Invalid argument in I: Webmyphpa. php on line 16
Open the php. ini file and find; extension = php_openssl.dll, remove double quotation marks ";". Restart the web server.
If the apache server is used, the mod_ssl module test can be enabled at the same time.
If it is not convenient to modify the server configuration, you can use the following functions to solve the problem:
Sample Code:
<? Php // file_get_contents captures the https address Content function getCurl ($ url) {$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false); $ result = curl_exec ($ ch); curl_close ($ ch ); return $ result ;}
Method 2:
In php, when the file_get_contents function is used to capture the website content starting with https, an error warning similar to the following occurs:
Warning: file_get_contents (https: // 127.0.0.1/index. php) [function. file-get-contents]: failed to open stream: Invalid argument in E: \ website \ blog \ test. php on line 25
Open php. ini and find; extension = php_openssl.dll, remove double quotation marks ";". Restart the web server.
Apache can enable the mod_ssl module for testing at the same time.
The above content is shared with you two ways to solve the problem of the file_get_contents function grabbing https address error in PHP. I hope it will be helpful to you.