rend 未定义,是什么原因?
来源:6-3 Swoole进程案例解刨
小白学编程666
2019-01-19
echo "process-start-time:".date('Y-m-d H:i:s').PHP_EOL;
$workers = [];
$curls = [
'http://baidu.com',
'http://sina.com.cn',
'http://qq.com',
'https://www.baidu.com/s?wd=imooc',
'https://www.baidu.com/s?wd=wnaglei',
'https://www.baidu.com/s?wd=wangmin',
];
for ($i=0; $i<6; $i++) {
$process = new swoole_process(function (swoole_process $worder) use($i, $curls) {
$content = curlData($curls[$i]);
// echo $content.PHP_EOL;
$worder->write($content.PHP_EOL);
}, true);
$pid = $process->start();
$workers[$pid] = $process;
}
foreach ($workers as $process) {
echo $process->rend();
}
function curlData($curl) {
sleep(1);
return $curl.'success'.PHP_EOL;
}
echo "process-end-time:".date('Y-m-d H:i:s').PHP_EOL;
报错:
process-start-time:2019-01-19 04:37:38
PHP Fatal error: Uncaught Error: Call to undefined method Swoole\Process::rend() in /Users/alanwang/wwwroot/demo/process/curl.php:31
Stack trace:
写回答
4回答
-
慕粉慕粉1888
2020-01-28
应该是read吧,你写成了rend
00 -
小白学编程666
提问者
2019-01-21
打印$process返回的
00 -
singwa
2019-01-19
同学您好。您打印$process 试试 看看返回什么内容呢?
print_r($process);
012019-01-21 -
singwa
2019-01-19
同学你好请问你的swoole是哪个版本?
012019-01-19
相似问题