The configuration of PHP is typically done in the php.ini file. The php.ini file is a crucial configuration file for PHP. It contains various settings that govern how PHP behaves on your server. These settings can control everything from resource limits to security features and performance optimizations.
Enabling short open tags in PHP allows developers to use the <?
and <? ?>
tags as shorthand for <?php
?>
.
To enable short open tags follow these general steps.
Enable short open tags
Find out php.ini location.
php --ini
Edit php.ini
Syntax
sudo nano /etc/php/<version>/cli/php.ini
Example
sudo nano /etc/php/8.1/cli/php.ini
Setting short_open_tag
to On
in the PHP configuration allows PHP code to be written with short tags (<? ?>
) instead of the standard <?php ?>
tags.
short_open_tag = On
To apply the changes, you need to restart the Apache web server.
sudo service apache2 restart
Possible issue
If the previous steps don’t work, try this.
Change permissions to full access to everyone.
sudo chmod -R 777 /etc/php/8.1/apache2
or use a safer approach to limit permissions to access the files within the apache2 directory. Then verify if the change has taken effect.
sudo chmod -R 644 /etc/php/8.1/apache2/php.ini
Edit php.ini file.
sudo nano /etc/php//apache2/php.ini
Set short_open_tag
to On
short_open_tag = On
Restart Apache service
sudo service apache2 restart