On 7/23/07, Ken Snyder <[EMAIL PROTECTED]> wrote:

Yay!! After more googling for "php background processing" and lots of
testing, I found a working cross-platform background-processing method
using functions popen() and pclose().  (Never heard of those
functions!)  It relies on the command line ampersand concept.

Explained here:

http://robert.accettura.com/archives/2006/09/14/asynchronous-processing-with-php/

See below for the heart of the idea.  Now if we can just spread the
word--this is a question that has come up on a zillion forums!

-- Ken


if (is_windows()) {
  // windows uses "start /b"
  pclose(popen('start /b ' . $call, 'r'));
} else {
  // *nix uses "/dev/null &"
  pclose(popen($call . ' /dev/null &', 'r'));
}
echo "<p>Called &quot;$call&quot; without waiting for a return value</p>";


Unix programmers should know about this.  It's a pipe.  It's part of *nix
InterProcess Communication (IPC) library.  I didn't realize PHP had this
functionality.  Check out man pages for Standard I/O functions (3S) popen
and pclose.

--
Scott Hill

"May you solve interesting problems" - Author Unknown
"A fanatic is one who can't change his mind and won't change the subject." -
Sir Winston Churchill

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to