note 54183 deleted from function.ignore-user-abort by didou
| From: | didou@php.net | Date: | Sat, 21 Mar 2009 11:03:21 +0000 |
| Subject: | note 54183 deleted from function.ignore-user-abort by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-152251@lists.php.net to get a copy of this message | ||
Note Submitter: Rustam
----
I wrote a simple function that can "spawn" another thread within the webserver by making
async http request. The page that is being spawned can call ignore_user_abort() and do whatever it
wants in the background...
<?php
function http_spawn($page)
{
$basepath=ereg_replace('[^/]*$', '', $_SERVER['PHP_SELF']);
$cbSock=fsockopen('localhost', $_SERVER['SERVER_PORT'], $errno, $errstr,
5);
if ($cbSock)
{
fwrite($cbSock, "GET {$basepath}{$page} HTTP/1.0\r\n"
."Host: {$_SERVER['HTTP_HOST']}\r\n\r\n");
}
}
?>
Example:
<?php
if ($search_initialized)
http_spawn("ftindex.php");
?>