dongzhan9100
2015-12-24 11:18
浏览 94
已采纳

HTML不显示字符

I'm running lighttpd 1.4.35 on Debian 8.2. I have a very simple html file with php code (php5) which calls a bash script and prints the output:

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

If that html file is called on firefox, the output is

 is the result

If I directly run php with that file (php index.php), the output is

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

So, where does the result get lost?


edit: The webpage source code from firefox is

<html>
<body>

 is the result</body>
</html>

edit: solved. bash script uses '~' which expands to wrong directory when the script is run from webserver.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dstbp22002 2015-12-24 11:37
    已采纳

    The exec functions "only" return the contents of stdout, which is why you might miss an error message.
    But you can redirect stderr to stdout, e.g. via

    $res = shell_exec("/var/www/html/run.sh 2>&1");
    
    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题