Home > Article > Backend Development > Solution to the error of grabbing https address by file_get_contents function in PHP (two methods), burpsuite grabbing https_PHP tutorial
Method 1:
In php, when crawling https websites, the following error content is prompted:
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 the double quotes ";" and restart the web server.
For apache server, mod_ssl module testing can be enabled at the same time.
If it is inconvenient to modify the server configuration, you can use the following function to solve the problem:
Code example:
<?php //file_get_contents抓取https地址内容 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 using the file_get_contents function to capture the content of a website whose URL starts with https, an error warning similar to the following will appear:
Warning: file_get_contents(https://127.0.0.1/index.php) [function.file-get-contents]: failed to open stream: Invalid argument in E:websiteblogtest.php on line 25
Open php.ini and find ;extension=php_openssl.dll. Remove the double quotes ";" and restart the web server.
Apache can enable mod_ssl module testing at the same time
The above content has shared with you two methods to solve the error of grabbing https address in PHP file_get_contents function. I hope it will be helpful to everyone.