Jump to content

Recommended Posts

It is a setting on the server. The problem with using the short tags (<?) is that the server admin could change the setting without the developer knowing, causing any scripts using short tags to fail until the developer realizes there is an issue.

 

The other problem is that if the developer decides to switch servers some day, and the new server doesn't support short tags, the script will fail.

 

As such it is considered bad practice to use short tags.

 

Link to comment
https://forums.phpfreaks.com/topic/108641-difference-between/#findComment-557170
Share on other sites

Even php.net itself recommends against using short open tags -

; NOTE: 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.

 

Short open tags also causes problems when xml is embedded in a php file, because the php parser was never made smart enough to know that <?xml is not a short open tag followed by the letters xml.

 

Several things were added in php's early versions to "magically" save a lazy-way programmer time when he was typing code, but in each of these (short open tags, magic quotes, register globlas...) they have caused much much more wasted time to troubleshoot the problems they caused in code that stops being parsed when moved between servers with different settings (short open tags), wasted execution time to remove slashes automatically added by the language because they don't escape all the special characters (magic quotes), or in hacked sites (register globals) then they ever saved the programmer when he was typing the code.

 

Programming languages should be a programming language first and a "magic" act - never. [/rant]

Link to comment
https://forums.phpfreaks.com/topic/108641-difference-between/#findComment-557362
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.