mercredi 25 octobre 2017

Run php daemon on web server

Im trying to write a chat script for my website. The idea is to run an infinite loop to check if any messages are incoming. I wrote a little test script to test this.

<?php

$test = false;

while(!$test) {
    if($test == true) {
        echo "<h1>hello</h1>";
    }
}

?>

<input type="button" onclick="<?php $test = true; ?>" />

Obviously the page doesn't load because of the infinite loop. How can I run a sort of daemon process on the side, so the page can load and function normally whilst continually checking for incoming messages?

Also, in the script shown above I understand that I could just use a function to receive the result but I don't really want to have to click a button every few seconds to check for incoming messages.

Thanks!




Aucun commentaire:

Enregistrer un commentaire