file_get_contents function in PHP to crawl HTTPS address error resolution method (two methods) _php instance

Source: Internet
Author: User

Method One:

In PHP, the Web site that captures HTTPS prompts the following error content:

Warning:file_get_contents () [function.file-get-contents]: Failed to open stream:invalid argument into i:webmyphpa.php on L INE 16

Open php.ini file Find; extension=php_openssl.dll, remove double quotes ";", restart the Web server.

Apache server, you can enable MOD_SSL module testing at the same time.

If it is not convenient to modify the server configuration, you can refer to the following functions to resolve:

code example:

<?php
//file_get_contents capture 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 Two:

In PHP, an error warning similar to the following occurs when you use the File_get_contents function to crawl the content of a Web page that is the beginning of https with the URL:

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 Find; extension=php_openssl.dll, remove double quotes ";", restart the Web server.

Apache can enable MOD_SSL module test at the same time

The above content to share two ways to solve PHP file_get_contents function crawl HTTPS address error, I hope to help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.