Home  >  Article  >  Backend Development  >  PHP simple function to obtain remote web page content

PHP simple function to obtain remote web page content

WBOY
WBOYOriginal
2016-07-25 08:54:25978browse
  1. $curDomain = $_SERVER['HTTP_HOST'];
  2. $strHTML = file_get_contents('http://bbs.it-home.org/DomainParking.asp?gDomName='.$curDomain );
  3. echo $strHTML
  4. ?>
Copy code

file_get_contents is unstable.

Encountered an error: file_get_contents(http://***.php): failed to open stream: HTTP request failed!

It is recommended to use curl method here.

>>>> Articles you may be interested in: php curl sample code for collecting off-site content Detailed explanation and usage of php curl parameters Solution to the problem of url Chinese encoding when php Curl grabs remote content php curl gets the API code for all information of the specified IP Detailed explanation of how to enable curl extension in php Simple example of php curl post Example code of php curl usage php curl collection Discuz code example How to use CURL to forge IP source in PHP php code for using curl to determine whether a remote file exists php curl learning summary



Statement:
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