简体   繁体   English

如何在PHP中获取系统命令执行的响应状态值

[英]How to get the response status value of system command execution in PHP

I want to know the response status of system command execution in PHP, I tried this below code , but it always returns 0 value ,Here is my code: 我想知道PHP中系统命令执行的响应状态,我在下面的代码中进行了尝试,但始终返回0值,这是我的代码:

<?php
system("ls -lrt ",$return_value);
echo $return_value;
?>

In bash,it uses 0 to express everything is ok. 在bash中,它使用0表示一切正常。 The command 'ls -lrt' will not fail, so it return 0. If you want to get output, you should use exec() 命令“ ls -lrt”不会失败,因此返回0。如果要获取输出,则应使用exec()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM