note 72650 deleted from function.fopen by didou
| From: | didou@php.net | Date: | Sun, 28 Jan 2007 05:40:05 +0000 |
| Subject: | note 72650 deleted from function.fopen by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-122285@lists.php.net to get a copy of this message | ||
Note Submitter: bosmeeuw at gmail dot com
Reason: bad code
----
Here's how to do non-blocking (asynchronous) http requests in PHP. The script beneath is handy
when you need to trigger a remote script which starts up a long process, and you don't care
about its output
<?php
$url = parse_url('http://www.example.com/slow_script.php');
$url['port'] = $url['port'] ? $url['port'] : 80;
$fp = fsockopen($url['host'],$url['port']);
fwrite(
$fp,
"GET {$url['path']}?{$url['query']} HTTP/1.0\r\n" .
"Host: {$url['host']}\r\n"
);
fclose($fp);
?>