note 20012 added to control-structures.declare

From: Date: Tue, 19 Mar 2002 07:45:15 +0000
Subject: note 20012 added to control-structures.declare
Groups: php.notes 
Request: Send a blank email to php-notes+get-27947@lists.php.net to get a copy of this message
Correction to above note: Apparently, the end brace '}' at the end of the statement causes a tick. So using ------------ declare (ticks=1) echo "1 tick after this prints"; ------------ gives the expected behavior of causing 1 tick. Note: the tick is issued after the statement executes. Also, after playing around with this, I found that it is not really the multi-tasking I had expected. It behaves the same as simply calling the functions. I.e. each function must finish before passing the baton to the next function. They do not run in parallel. It also seems that they always run in the order in which they were registered. So, ------------ # register tick functions register_tick_function ("a"); register_tick_function ("b"); # make the tick functions run declare (ticks=1); ------------ is equivalent to ------------ a(); b(); ------------ It is simply a convenient way to have functions called periodically while some other code is being executed. I.e. you could use it to periodically check the status of something and then exit the script or do something else based on the status. -- http://www.php.net/manual/en/control-structures.declare.php http://master.php.net/manage/user-notes.php?action=edit+20012 http://master.php.net/manage/user-notes.php?action=delete+20012 http://master.php.net/manage/user-notes.php?action=reject+20012

« previous php.notes (#27947) next »