PDA

Click to See Complete Forum and Search --> : PHP not showing echo messages?


Franjdea
May 14th, 2010, 03:49 PM
Hey guys,

I've got a problem where my page, after you login, only displays normal HTML and not PHP code. Here is the code, I don't know what is wrong. Thank you.


<?
session_start();

echo "This doesn't show either";

if(!session_is_registered(myusername)){
header("location:index.php");
}



?>

<html>
<body>
<p>Login Successful :D</p>
</body>
</html>


Thanks,

-Francis

kows
May 14th, 2010, 04:00 PM
view the source. I bet the source you get is everything you posted (PHP included, which shouldn't happen normally). your script is most likely not even being parsed. short tags are (possibly, I forget) deprecated -- but even if they aren't, they're sort of bad practice to use because not all servers enable short tags. thus, you should be using the full <?php opening tag.

Zach_VB6
May 28th, 2010, 11:41 AM
It depends on the short_open_tag setting in your php.ini. The idea of using a (long) tag is a very good idea as it gives your code portability to servers where short_open_tag is Off. Here's a way to check if short_open_tag is on or off:<?PHP
echo 'Short-Tag usage is <strong>',(ini_get('short_open_tag') == 1 ? 'on.' : 'off.'),'</strong>';
?>Alternatively, you can CTRL+F through phpinfo() for short_open_tag.