且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php exec和shell_exec无法正常工作

更新时间:2022-02-21 01:52:37

One of the comments on the shell_exec manual page says:

请注意以下不一致之处:shell_exec()和backtick运算符将在命令输出为空时不返回字符串-而是返回NULL.

Beware of the following inconsistency: shell_exec() and the backtick operator will not return a string if the command's output is empty -- they'll return NULL instead.

这将与''返回false进行严格比较.

This will make strict comparisons to '' return false.


如果PHP处于安全模式,则可能已禁用a>.

shell_exec()(反引号的功能等效项)
当PHP以安全模式运行时,此功能被禁用.

shell_exec() (functional equivalent of backticks)
This function is disabled when PHP is running in safe mode.

exec()
您只能在safe_mode_exec_dir中执行可执行文件.出于实际原因,当前不允许在可执行文件的路径中包含..组件. escapeshellcmd()在此函数的参数上执行.

exec()
You can only execute executables within the safe_mode_exec_dir. For practical reasons it's currently not allowed to have .. components in the path to the executable. escapeshellcmd() is executed on the argument of this function.

您可以使用 phpinfo() 检查服务器的PHP设置.功能.

You can check your server's PHP settings with the phpinfo() function.