dongying9756 2012-03-12 21:24
浏览 14
已采纳

PHP代码可在网站上查看?

Why is the below code displaying the php code from msg.php?

$flag = file('msg.php');
$content = "";
foreach ($flag as $value) {
    $content .= $value;
}
echo $content;

Is there a way I can stop it displaying the PHP code?

  • 写回答

6条回答 默认 最新

  • doukui2011 2012-03-12 21:28
    关注

    You're outputting it as text with echo and reading it with file, neither of which will execute any PHP. Your example can be replaced with:

    require 'msg.php';
    

    and everything will work properly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?