gpt4 book ai didi

php-系统函数-/usr/bin/echo Hello : No such file or directory

转载 作者:太空宇宙 更新时间:2023-11-04 03:49:49 25 4
gpt4 key购买 nike

我是 PhP 新手。
当我在 php 中使用 System 函数运行 Linux 终端命令时,我在 error_log 中收到错误。
这是我的代码:

if(isset($_POST['submit_button']))
{
$name=$_POST['User_name']; // here $name contains 'John'
echo '<pre>';

$command="/usr/bin/echo $name";
$command1="'".$command."'";
$last_line = system($command1, $retval);

echo '</pre>
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;
}

当我运行此代码时,出现以下错误:

in browser - giving code : 127  


in /var/log/httpd/error_log file - sh: /usr/bin/echo John: No such file or directory

我错过了什么吗?
提前致谢。

最佳答案

仅尝试使用 echo,而不是使用/usr/bin/echo
更改命令变量声明如下:

$command="echo $name";

关于php-系统函数-/usr/bin/echo Hello : No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26729707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com