【发布时间】:2015-01-14 15:40:10
【问题描述】:
我知道当我分叉进程时,子进程会获得一个新的内存副本,我可以访问父变量但我无法修改。
<?php
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
$b = "XXX";
// we are the parent
} else {
// we are the child
echo $b; // prints XXX
$b = "YYY"; // only changes $b in the child, $b in parent isn't affected
}
?>
我如何从孩子向父母发送消息?我需要发送一个数组结构
【问题讨论】:
-
你的问题不清楚。
-
对不起,我更新了问题是“我如何才能将消息从孩子发送给父母?”。我英语不好。