note 34326 deleted from function.pcntl-fork by nlopess

From: Date: Sat, 22 Jul 2006 11:38:31 +0000
Subject: note 34326 deleted from function.pcntl-fork by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115041@lists.php.net to get a copy of this message
Note Submitter: porkchop at porkchop dot net ---- On a fork, vars themselves are copied into the new child's space, not just a refrence to that var. Consider: <? $foo="foo"; $pid=pcntl_fork(); if($pid != 0) { /* we're here if this is the parent */ $foo="bar"; echo $foo; // returns "bar". die("Child complete"); } else { /* we're the child */ sleep 5 echo $foo; // returns "foo" even though the parent set $foo to "bar" about 5 seconds earlier. }; ?>

« previous php.notes (#115041) next »