HTML 不显示字符

HTML not showing characters

我在 Debian 8.2 上 运行ning lighttpd 1.4.35。我有一个非常简单的 html 文件,其中包含 php 代码 (php5),它调用 bash 脚本并打印输出:

<html>
<body>
<?php
    $res = shell_exec("/var/www/html/run.sh");
    echo $res . " is the result";
?>
</body>
</html>

如果在 firefox 上调用 html 文件,输出为

 is the result

如果我直接运行 php那个文件(php index.php),输出是

<html>
<body>
13.00
 is the result</body>
</html>

那么,结果在哪里丢失了?


编辑: 来自firefox的网页源码是

<html>
<body>

 is the result</body>
</html>

编辑:已解决。 bash 脚本使用“~”,当脚本来自网络服务器 运行 时,它会扩展到错误的目录。

如果您处于 安全模式

shell_exec 不会 运行,这可能是问题所在

exec 函数 "only" return stdout 的内容,这就是您可能错过错误消息的原因。
但是你可以 redirect stderr 到标准输出,例如通过

$res = shell_exec("/var/www/html/run.sh 2>&1");