If PHP is not accepting the <?
tag and is only accepting the <?php
and <script>
tags, it is likely that the short_open_tag setting in your PHP configuration is disabled.
By default, the short_open_tag setting is disabled in PHP 5.3.x and later versions. This means that you will need to use the <?php
tag to enclose PHP code, rather than the shorter <?
tag.
If you want to enable the use of the <?
tag, you will need to edit the PHP configuration file (usually php.ini
) and set the short_open_tag setting to On
.
To do this, open the php.ini
file in a text editor and search for the short_open_tag
setting. It should be set to Off
by default. Change it to On
and save the file.
Then, restart the web server to apply the changes.
short_open_tag = On
It's important to note that using the <?
tag is not recommended as it may not be supported in future versions of PHP. It is generally better to use the <?php
tag to enclose PHP code, as it is more portable and less prone to conflicts with other languages or systems.