Solution to the error in grabbing https address by file_get_contents function in PHP

不言
Release: 2023-03-29 12:56:01
Original
2582 people have browsed it

This article uses two methods to solve the error of grabbing the https address in the file_get_contents function in PHP. Friends in need can refer to the following

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 the Apache server, you can enable mod_ssl module testing at the same time.

If it is inconvenient to modify the server configuration, you can refer to the following function to solve the problem:

Code example:


        
Copy after login

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:\website\blog\test.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 the mod_ssl module test at the same time

The above content has shared with you two methods to solve the error of grabbing the https address in the file_get_contents function in PHP. I hope it will be helpful to everyone.

Related recommendations:

Header usage and basic functions in PHP

Detailed explanation of count function examples in PHP

Detailed explanation on the usage of spl_autoload_register() function in PHP

##

The above is the detailed content of Solution to the error in grabbing https address by file_get_contents function in PHP. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!