PHP Not Accepting <? Tag; Only Accepting <?php and <script> Tag

I am using PHP along with the latest version of Apache web-server. Only <?php and <script> tags are recognized by my LAMP setup. Many of my scripts are broken. How do I allow the <? tag also?

You need to allow the <? tag by editing the php.ini file. 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.

Configuration

Open php.ini ( /etc/php.ini or /usr/local/etc/php.ini) using a text editor such as vi/nano, enter (your must be root user to edit php.ini file):
# vi php.ini
Set short_open_tag to On:
short_open_tag = On
Save and close the file. Restart the apache web-server (centos/rhel 6.x or older):
# service httpd restart
OR (FreeBSD)
# /usr/local/etc/rc.d/apache22 restart
OR (systemd centos/rhel 7)
# systemctl restart httpd.service

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.