PHP file_get_contents function Crawl HTTPS address error resolution (two methods) _php instance

Source: Internet
Author: User
method One:

In PHP, crawl HTTPS web site, prompting the following error content:

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

Open the php.ini file to find; Extension=php_openssl.dll, remove the double quotation mark ";" and restart the Web server.

Apache server, you can enable the Mod_ssl module test at the same time.

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

code example:

<?php//file_get_contents Crawl HTTPS address contents 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, when you use the File_get_contents function to crawl Web page content with URLs that begin with HTTPS, you receive an error warning similar to the following:

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 the double quotation mark ";", restart the Web server.

Apache can enable Mod_ssl module testing at the same time

The above content to share two ways to solve PHP file_get_contents function crawl HTTPS address error, we 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.