I am reading a PHP book. The book tells me that PHP should begin with a <?PHP and end with ?>
I am looking at some consultant code and see the PHP starting with <? and ending with ?>
Is there a difference?
I am reading a PHP book. The book tells me that PHP should begin with a <?PHP and end with ?>
I am looking at some consultant code and see the PHP starting with <? and ending with ?>
Is there a difference?
Yes,
You should always do <?php and ?>
The <? is called short_open_tags and must be turned on in your php.ini to use it, I don’t recommend it.
There is a whole laundry list of reason why you don’t won’t to use it.
"Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server. For portable, redistributable code, be sure not to use short tags."
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.
Thanks.
^ what topcoder said, but just to clarify something
[php]<?php
This is called a shorthand echo, and is not the same as short tags, shorthand echoes are on by default from PHP 5.4 (where they were taken out of the short open tags setting) and should be safe for use also in the future. It’s a nice feature when templating.