开发者

How to hide not rendered php code?

Here's the question. I have some kind of php script. and then html like this:

<?
foreach($_POST as $name=>$val){
        $body .= $name." : ".$val."\n";
    }
    mail("someemail@e.com","title",$body);
}   
?>

So, when this code executes successfully, everything is fine. But when code does not execute(for example if I do not have smtp ser开发者_如何学JAVAver), then I got this on my html page: $val){ $body .= $name." : ".$val."\n"; } mail("someemail@e.com","title",$body); } ?>

How do I hide this code, so it does not show on my page? Thanks.


It's possible that the server does not have the short opening tag enabled.

At the top of the file, use <?php instead of just <?.

You should do this in any case where you do not control the server that your code will run on.


The code would not show up just because you don't have an SMTP server. The only reasons it would appear are

  1. If the server doesn't have PHP installed
  2. Apache isn't configured properly
  3. The file doesn't have an extension of .php
  4. Or you're not viewing the file through the server.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜