<?php header('access-allow-origin:*'); sleep(1); echo "hello\n"; echo "world";
<?php $url = 'http://localhost/test.php'; $output = file($url); var_dump($output);
b. 输出:
array(2) { [0]=> string(6) "hello" [1]=> string(5) "world" }
<?php $url = 'http://localhost/test.php'; $output = file_get_contents($url); var_dump($output);
b. 输出:
string(11) "hello world"
<?php $url = 'http://localhost/test.php'; $handle = fopen($url,"rb"); do{ $data = fread($handle,1024); if(strlen($data)==0) { break; } $output = $data; } while(true); fclose($handle); var_dump( $output);
b. 输出:
string(11) "hello world"
<?php $url = 'http://localhost/test.php'; $ch = curl_init(); $timeout = 1; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $output = curl_exec($ch); curl_close($ch); var_dump($output);
b. 输出:
string(11) "hello world"
<?php $url = 'localhost/test.php'; $fp = fsockopen($url, 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { stream_set_blocking($fp,0); $out = "GET / HTTP/1.1\r\n"; $out .= "Host: {$url}\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { var_dump(fgets($fp, 128)); } fclose($fp); }
b. 输出:
string(11) "hello world"
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。