Page 1 of 1

php not displaying correctly

Posted: Thu Jan 22, 2009 6:27 pm
by kidrandom
I have just started learning PHP from a training Cd but I'm having trouble with a script not displaying properly. I'm Running mac os x 10.5.5

Personal web sharing activated apache running, I have edited httpd.conf and removed the # from
LoadModule php5_module libexec/apache2/libphp5.so

made a simple page in php

Code: Select all

<?php echo("hello world "); ?>
saved the page /user/Sites/index.php
and doesn't displays a blank page in the browser. Also when I view the source code the php lines are visible and highlighted pink.

A PHPtest page with the PHP code:

Code: Select all

<?php phpinfo(); ?>
works, and displays the Entropy version correctly.

Can anyone point me in the correct direction

Thanks for your answers guys. I have been writing my code in full php tags I just didn't write it in on this post. Sorry about that. I've edited it above.

Re: php not displaying correctly

Posted: Thu Jan 22, 2009 6:31 pm
by Stryks
How does your simple page work if you go ...

Code: Select all

<?php
print("hello world ");
 
?>
(note the semicolon at the end of the line and the full php tags)

Re: php not displaying correctly

Posted: Thu Jan 22, 2009 7:34 pm
by califdon
kidrandom wrote:

Code: Select all

<?
print("hello world ")
?>
A PHPtest page with the PHP code:

Code: Select all

<?php phpinfo(); ?>
works, and displays the Entropy version correctly.
Probably your Apache is configured to not recognize "short PHP open" tags ( <? ), which should never be used in the first place, contrary to what some tutorials show you. The "long PHP open" tag ( <?php ) should be used in every case.

This explains why the second one works but the first one doesn't.