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
- If the server doesn't have PHP installed
- Apache isn't configured properly
- The file doesn't have an extension of
.php
- Or you're not viewing the file through the server.
精彩评论