If you want to create a daemon in PHP, consider using System_Daemon http://pear.php.net/package/System_Daemon
Install it like this:
pear install -f system_daemon
Then use it like this:
<?php
// Include PEAR's Daemon Class
require_once "System/Daemon.php";
// Bare minimum setup
System_Daemon::setOption("appName", "mydaemonname");
// Spawn Deamon!
System_Daemon::start();
// Your PHP Here!
while (true) {
doTask();
}
// Stop daemon!
System_Daemon::stop();
?>
More examples can be found inside the PEAR package.