Home  >  Article  >  Backend Development  >  PHP function to obtain remote web page content_PHP tutorial

PHP function to obtain remote web page content_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:44:34775browse

$curDomain = $_SERVER['HTTP_HOST'];
$strHTML = file_get_contents('http://www.jb51.net/DomainParking.asp?gDomName='.$curDomain);
echo $strHTML
?>
I have seen on the Internet that file_get_contents is unstable, and I have encountered it. . .
On the other hand, it also shows that the fault tolerance of the program is very poor. . .
Well, let’s get down to business.
I encountered this error:
file_get_contents(http://***.php): failed to open stream: HTTP request failed!
After a while, I decided to use curl

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320507.htmlTechArticle?php $curDomain = $_SERVER['HTTP_HOST']; $strHTML = file_get_contents('http://www .jb51.net/DomainParking.asp?gDomName='.$curDomain); echo $strHTML ? I have seen on the Internet that file_get...
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