...

View Full Version : <?php ?>



phantom007
06-09-2007, 06:06 PM
For some reasons my php code does not work unless i put the php keyword after the ? in my code as shows in the following example.


<?php
echo "Hello";
?>
The above code works




<?
echo "Hello";
?>
The above code does not work


What settings do i need to do to make the second code work?

Thanx

Alex!
06-09-2007, 06:25 PM
Is there a reason why you want to use <? instead of <?php ?

AFAIK <?php is the preferred tag anyway...

Alex

phantom007
06-09-2007, 06:27 PM
Coz Thats a shortcut and I have seen many times people using <? instead of <?php

CFMaBiSmAd
06-09-2007, 06:48 PM
The short open tag <? is NOT server independent and also causes problems with xml code inside of php files. Php.net itself cautions against using it when writing portable code that will work on any server.

Don't use it.

matak
06-09-2007, 07:37 PM
For some reasons my php code does not work unless i put the php keyword after the ? in my code as shows in the following example.


<?php
echo "Hello";
?>
The above code works




<?
echo "Hello";
?>
The above code does not work


What settings do i need to do to make the second code work?

Thanx


you need to enable short tags in php.ini

find this short_open_tag and set it to On


short_open_tag = On

whizard
06-10-2007, 03:06 AM
How hard is it to type

<?php instead of <?

?

The best way is to write out the whole opening tag, and it requires almost zero extra effort.. I would stick with that!

Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum