- function async_exec($url){
- if(strtolower(substr($url, 0 ,7)) == 'http://'){
- $u = parse_url($url);
- $host = $u['host'];
- } else {
- $host = $_SERVER['HTTP_HOST'];
- }
- if (function_exists ( fsockopen )) {
- $fp = fsockopen ( "{$host}", 80, $errno, $errstr, 10 );
- } else {
- $fp = pfsockopen ( "{$host}", 80, $errno, $errstr, 10 );
- }
- if (! $fp) {
- echo "{$errstr} {$errno} <br />\\n";
- } else {
- $out = "GET {$url} HTTP/1.1\\r\\n";
- $out .= "Host: {$host}\\r\\n";
- $out .= 'Connection: Close
- ';
- fwrite ( $fp, $out );
- //忽略执行结果
- //while (!feof($fp)) {
- //echo fgets($fp, 128);
- //}
- fclose ( $fp );
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/2609201513737.html
来源: http://www.codesnippet.cn/detail/2609201513737.html