<?php
/*
I don't have a linux system to test this on, but this should work heh.
what's interesting is that even though it's one script, it's running two while(1) loops at the same time.
*/
$id=pcntl_fork(); //request a fork of this process. this code you are looking at is 'the parent'. worry about the child in a sec.
if ($id==-1) die("ah crap, your system doesn't support forking. =("); //error handler
if ($id) { //only the parent process will know what this is, so if it does, we must be 'the parent'.
while(1) {
echo "I am the parent and I like it!\r\n";
sleep(1);
}
} else { //guess we're the child
while(1) {
echo "I am the child and I hate my parent!\r\n";
sleep(1);
}
}
?>