美文网首页
php exec返回详细报错信息

php exec返回详细报错信息

作者: Tsun424 | 来源:发表于2017-12-19 17:36 被阅读0次

php exec执行后返回一个 数字,0表示执行成功, 如果是非0,则说明有错误发生,但通过这个数字经常无法得到详细错误信息。
可以通过在命令后加2>&1,这样就会将错误详细信息赋给$output。

exec('ls 2>&1', $output, $return_val);   
var_dump($output);  

相关文章

网友评论

      本文标题:php exec返回详细报错信息

      本文链接:https://www.haomeiwen.com/subject/hydiwxtx.html