一个使用php做多进程的例子
yorgo 2001-07-25 03:06:54 PHP is not multithreaded. The "Ticks" feature is a way to get some of the benefits of multithreading.
<?
function foo($str) {
static $i = 0;
print "$str: $i<br>\n";
$i++;
}
register_tick_function("foo", "count");
declare (ticks = 6) {
for($i=0; $i<20; $i++) {
echo "$i<br>\n";
}
}
?>
Output:
0
1
2
count: 0
3
4
5
count: 1
6
7
8
count: 2
9
10
11
count: 3
12
13
14
count: 4
15
16
17
count: 5
18
19
count: 6
欢迎大家激烈讨论