PHP: Tags Not Working in PHP 5.3.x under UNIX / Linux

In PHP 5.3 and later versions, the short open tag <? is disabled by default, meaning that it won’t be interpreted as the start of a PHP block. This change was made to allow for better compatibility with XML, where the <? character sequence is used to define processing instructions.

To resolve the issue of <? not working in PHP 5.3, you have a few options:

  1. Use the long open tag <?php instead of <?:
<?php
// your PHP code here
?>
  1. Enable the short open tag in the PHP configuration file (php.ini):
short_open_tag = On
  1. Put the following line of code at the top of your script to enable short open tags for just that script:
<?php
ini_set("short_open_tag", 1);
?>

It’s recommended to use the long open tag <?php instead of the short open tag <?, as it is more widely supported and less likely to cause compatibility issues with other systems and software. If you choose to enable short open tags, make sure to use a consistent syntax in all of your scripts, and keep in mind that your code may not be compatible with other systems that use a different PHP version or configuration. (Modafinil)

Leave a Comment