Skip to main content



How to Enable PHP Short Tags on Your Hosting Account

How to Enable PHP Short Tags on Your Hosting Account

If you have ever worked with legacy PHP applications or older content management systems, there is a good chance you have come across PHP short tags. These are the abbreviated versions of the standard PHP opening tag, and whilst they can make code look cleaner and more concise, they are not always enabled by default on hosting accounts. In this guide, we will walk you through everything you need to know about PHP short tags hosting, including what they are, why they matter, and how to enable them across different hosting environments.

What Are PHP Short Tags?

In standard PHP, code blocks are opened with <?php and closed with ?>. PHP short tags allow developers to use a shortened version of the opening tag, specifically <? instead of <?php. There is also an echo short tag, <?=, which is used as a shorthand for <?php echo.

For example, instead of writing:

<?php echo $variable; ?>

You could write:

<?= $variable; ?>

The echo short tag (<?=) has actually been enabled by default since PHP 5.4, regardless of the short_open_tag setting. However, the plain <? short tag still requires explicit activation in the PHP configuration.

Why PHP Short Tags Are Disabled by Default

The main reason hosting providers tend to disable PHP short tags is to avoid conflicts with XML declarations. XML documents begin with <?xml, which closely resembles a PHP short tag. If short tags are enabled and PHP encounters an XML declaration, it may attempt to parse it as PHP code, causing errors and broken pages.

Additionally, the PHP documentation itself has historically discouraged the use of short tags for portability reasons. If you are writing code that needs to run on multiple servers with varying configurations, relying on short tags could lead to unexpected failures. That said, many existing applications and templates still use them, which is why knowing how to manage PHP short tags hosting settings remains an important skill.

How to Check Whether PHP Short Tags Are Currently Enabled

Before making any changes, it is worth confirming whether short tags are already active on your hosting account. The simplest way to do this is by creating a PHP info file.

Using phpinfo()

Create a new file called phpinfo.php in your web root directory and add the following code:

<?php phpinfo(); ?>

Upload the file to your server and visit it in your browser. Search for short_open_tag in the output. If it shows On, short tags are already enabled. If it shows Off, you will need to enable them using one of the methods described below. Remember to delete this file after checking, as it exposes sensitive server information.

Methods to Enable PHP Short Tags on Your Hosting Account

There are several ways to enable PHP short tags, depending on the level of access you have to your hosting environment. Below, we cover the most common approaches.

Method 1: Editing the php.ini File

The most direct way to enable PHP short tags is by editing your php.ini configuration file. This is the master configuration file for PHP on your server.

Log in to your hosting control panel and navigate to the File Manager, or connect via FTP. Look for the php.ini file in your root directory. If one does not exist, you can create a new one. Add or update the following line:

short_open_tag = On

Save the file and restart your web server if you have the ability to do so. On shared hosting, changes typically take effect automatically or after a short delay. Verify the change by revisiting your phpinfo.php file.

Method 2: Using the .htaccess File

If you are on a shared hosting account that uses Apache, you may be able to enable PHP short tags through your .htaccess file. This method works when the hosting provider allows PHP settings to be overridden at the directory level.

Open or create the .htaccess file in your web root and add the following line:

php_value short_open_tag 1

Save the file and test your site. Note that this method will not work on all hosting accounts, particularly those using PHP-FPM or FastCGI, as these configurations often restrict .htaccess overrides for PHP settings.

Method 3: Using the Hosting Control Panel

Many modern hosting control panels, including cPanel and Plesk, provide a graphical interface for managing PHP settings. This is often the easiest route for those who are not comfortable editing configuration files manually.

In cPanel, look for the MultiPHP INI Editor under the Software section. Select the domain or directory you want to configure, then locate the short_open_tag option and toggle it on. Save your changes and verify using the phpinfo method described earlier.

In Plesk, navigate to Domains, select your domain, and click on PHP Settings. From there, you can search for and enable the short open tag directive.

Method 4: Contacting Your Hosting Provider

If none of the above methods work, or if you do not have sufficient permissions to modify PHP settings yourself, your best option is to contact your hosting provider’s support team directly. Explain that you need the short_open_tag directive enabled for your account. Most reputable hosting companies will be able to assist you promptly.

For more helpful guides on managing your hosting environment, visit the DA Manager Blog, where you will find a range of tutorials covering everything from server configuration to domain management.

Important Considerations Before Enabling PHP Short Tags

Compatibility with Modern PHP

Whilst enabling short tags can solve immediate compatibility issues with older scripts, it is worth noting that modern PHP development best practices discourage their use. If you are building a new application or updating an existing one, consider refactoring the code to use full PHP tags. This will make your code more portable and future-proof.

Security Implications

Enabling PHP short tags does not introduce direct security vulnerabilities, but it does add another layer of complexity to your server configuration. Keeping your PHP configuration as clean and standard as possible reduces the risk of unexpected behaviour and makes troubleshooting easier.

Testing After Changes

Whenever you modify PHP configuration settings, always test your website thoroughly afterwards. Check key pages, forms, and any dynamic functionality to ensure nothing has broken as a result of the change.

Conclusion

Understanding how to manage PHP short tags hosting settings is a valuable skill for anyone running PHP-based websites or applications. Whether you are maintaining a legacy system or simply trying to get an older script running correctly, the methods outlined in this guide should help you get things working smoothly. Always remember to document any changes you make to your server configuration, and test thoroughly after each modification to ensure your site continues to function as expected.


This article was originally published in 18 June 2026. It was most recently updated in June 18, 2026 by isaiah

Leave a Reply