file_get_contents获取不到网页内容的解决方法_php技巧
May 17, 2016 am 09:06 AM$url = "http://jb51.net/index.html";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
//在需要用户检测的网页里需要增加下面两行
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//curl_setopt($ch, CURLOPT_USERPWD, US_NAME.":".US_PWD);
$contents = curl_exec($ch);
curl_close($ch);
echo $contents;
?>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

如何解决PHP Warning: file_get_contents(): failed to open stream: HTTP request failed

How to solve PHP Warning: file_get_contents(): Filename cannot be empty

PHP's file_get_contents() function: How to read contents from a file

Detailed explanation of PHP file caching functions: file caching processing methods of file_get_contents, file_put_contents, unlink and other functions

PHP function introduction—file_get_contents(): Read the contents of the URL into a string

How to read file contents using file_get_contents function in PHP

Detailed explanation of PHP 5.2 functions: How to use the file_get_contents function to read file contents

PHP function introduction—file_get_contents(): Read file contents into a string
