php not displaying correctly

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kidrandom
Forum Newbie
Posts: 2
Joined: Thu Jan 22, 2009 5:26 pm

php not displaying correctly

Post 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.
Last edited by kidrandom on Fri Jan 23, 2009 3:53 am, edited 1 time in total.
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: php not displaying correctly

Post 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)
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: php not displaying correctly

Post 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.
Post Reply