Page 1 of 1

<? Vs <?php when running files

PostPosted: 14. January 2013 00:53
by mercurymike
Hi,
and thanks in advance for helping out and any time you can provide to me to sort this out.

When I run .php files if the code is encapsulated in <? ... ?> rather than <?php ... ?> it will fail. In the former code it will be displayed as plain text (am assuming that Apache is looking for <?php at the start of the code segment to understand that it is to be ran as PHP code). Is there a way I can reconfigure it to understand that <? ... ?> is the same as <?php ... ?>.

Took me three hours to work out I was having this issue, as all my code is written with <? ... ?> as the standard.

Thanks again

Mike

Re: <? Vs <?php when running files

PostPosted: 14. January 2013 01:00
by JJ_Tagy
Check your php.ini

Re: <? Vs <?php when running files

PostPosted: 14. January 2013 01:04
by mercurymike
thanks JJ. My brain was turning to mush. Probably the Scottish weather and the time of night affecting my febrile brain.

Re: <? Vs <?php when running files

PostPosted: 14. January 2013 23:59
by hackattack142
As a side note, it is generally recommended that you do not use the shortcut.

From the php.ini
; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php and ?> tag combination. With the wide spread use
; of XML and use of these tags by other languages, the server can become easily
; confused and end up parsing the wrong code in the wrong context. But because
; this short cut has been a feature for such a long time, it's currently still
; supported for backwards compatibility, but we recommend you don't use them.