php - HTML 不显示字符

标签 php html firefox lighttpd

我在 Debian 8.2 上运行 lighttpd 1.4.35。我有一个非常简单的带有 php 代码 (php5) 的 html 文件,它调用 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 脚本使用“~”,当脚本从网络服务器运行时,它会扩展到错误的目录。

最佳答案

exec 函数“仅”返回 stdout 的内容,这就是为什么您可能会错过错误消息的原因。 但是你可以redirect stderr到标准输出,例如通过

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

关于php - HTML 不显示字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34451977/

相关文章:

jquery选择点击和firefox

php - PHP 脚本可以在收到所有 POST 数据之前启动吗?

html - 在 HTML 中显示僧伽罗语字母

javascript - AngularJS JSON 检查对象

html - 元素对齐有什么问题

javascript - Firefox 中屏幕外 Canvas 的性能问题

firefox - HTTPS 连接对 Chrome 有效,对 Firefox 无效

php - 如何在 PHP 脚本中确定 Ajax 请求被取消

php - 从文件 PHP 中删除前 X 行

php - Yii - 方法在此 View 中包含另一个 View