Home >Backend Development >PHP Tutorial >php中调用popen执行命令行,总返回segmentation fault。但是单独执行命令行就没有问题

php中调用popen执行命令行,总返回segmentation fault。但是单独执行命令行就没有问题

WBOY
WBOYOriginal
2016-06-23 13:30:191410browse

代码如下:

$cli = '/path/program getvar 2>&1 ';$handle = popen($cli, 'r');$read = fread($handle, 1024);pclose($handle);

请问是什么原因导致的,我该怎么查问题?


回复讨论(解决方案)

Segmentation fault
记忆体区段错误; 

Segmentation fault
记忆体区段错误; 


哥们,您这不是废话吗?

$handle = popen($cli, 'r');

var_dump($handle); // 看看有什么。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php中浮点数计算问题Next article:PHP表单之GET&POST