note 20010 modified in control-structures.declare by vrana
| From: | vrana@php.net | Date: | Thu, 05 Aug 2004 18:11:30 +0000 |
| Subject: | note 20010 modified in control-structures.declare by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74048@lists.php.net to get a copy of this message | ||
Here is an example of multi-tasking / multi-threading:
<?php
# declare functions
function a() {
echo "a";
}
function b() {
echo "b";
}
# register tick functions
register_tick_function ("a");
register_tick_function ("b");
# make the tick functions run
declare (ticks=1);
# that's all there is to it.
?>
Notes:
This will make functions a and b run once each at the same time.
If you try:
declare (ticks=1) {
1;
}
They will run twice each. That is because it seems to be an undocumented fact that there is always
an extra tick.
Therefore:
declare (ticks=2) {
1;
}
Will cause them to run once.
--was--
Here is an example of multi-tasking / multi-threading:
# declare functions
function a() {
echo "a";
}
function b() {
echo "b";
}
# register tick functions
register_tick_function ("a");
register_tick_function ("b");
# make the tick functions run
declare (ticks=1);
# that's all there is to it.
Notes:
This will make functions a and b run once each at the same time.
If you try:
declare (ticks=1) {
1;
}
They will run twice each. That is because it seems to be an undocumented fact that there is always
an extra tick.
Therefore:
declare (ticks=2) {
1;
}
Will cause them to run once.
http://php.net/manual/en/control-structures.declare.php