PHP simple function to obtain remote web page content

WBOY
Release: 2016-07-25 08:54:25
Original
1011 people have browsed it
  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



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
Popular Tutorials
More>
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!