Skip to main content

PHP short tags are an abbreviated way of opening PHP code inside a file. They are sometimes used by older PHP applications and templates, but they are not enabled in every hosting environment. If a legacy script relies on the short opening tag, <?, it may display PHP code as text or fail to run when the server does not recognise that syntax.

This guide explains what PHP short tags are, how they differ from the echo shorthand, and how to check and change the short_open_tag setting on a supported hosting account. It covers cPanel, php.ini, .user.ini, Apache configuration and Plesk, with notes about PHP handlers and common errors.

Important: Enabling short tags is mainly a compatibility measure for older code. For new PHP development, use the full <?php opening tag. The short echo form <?= is available independently of the short_open_tag setting.

What Are PHP Short Tags?

PHP code is normally enclosed between an opening tag and a closing tag:

<?php
echo "Hello, world!";
?>

The short opening tag uses <? instead of <?php:

<?
echo "Hello, world!";
?>

The PHP configuration directive short_open_tag determines whether PHP recognises this abbreviated opening form. It is a per-directory configuration setting, but the methods available to change it depend on the server API and hosting setup.

What is the short echo tag?

The short echo tag, <?=, is shorthand for outputting an expression:

<?= htmlspecialchars($name, ENT_QUOTES, 'UTF-8') ?>

This is equivalent to:

<?php echo htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); ?>

The <?= form has been available regardless of the short_open_tag setting since PHP 5.4. Turning on short_open_tag is therefore not necessary just to use the short echo syntax.

Why Do Some Applications Require Short Tags?

Some older scripts, templates and content management systems were written using <? as their PHP opening tag. If the server does not recognise that form, PHP may not parse the code as expected. Enabling the directive can help maintain compatibility while you plan an upgrade or code refactor.

There is also a potential conflict with XML declarations. An XML declaration begins with <?xml. If short tags are enabled and that declaration appears in a PHP-parsed file outside a PHP string or output statement, PHP may interpret it as the start of PHP code and report a parse error. This is one reason to prefer the full PHP opening tag in new projects and to test legacy applications carefully.

How to Check Whether PHP Short Tags Are Enabled

Check the active setting before changing anything. The configuration displayed by a control panel or a command-line PHP installation may differ from the setting used by the website, so verify the web PHP environment for the affected domain.

Option 1: Check with a temporary PHP configuration file

Create a temporary file in the website’s document root, for example check-php-setting.php, containing:

<?php
echo 'short_open_tag: ';
var_export(ini_get('short_open_tag'));
?>

Open the file through the website’s HTTPS URL. The result should show whether the setting is enabled for that request. Delete the file immediately after checking it. Do not leave diagnostic scripts accessible on a live website.

You can also use phpinfo() to inspect the PHP configuration, but it reveals considerably more server information. If you use it, restrict access and remove the file as soon as you have finished.

Option 2: Check through cPanel

If your hosting account uses cPanel, open Software → MultiPHP INI Editor, select the relevant domain and review the available directives. If short_open_tag is listed, check its current value. The exact controls available depend on the PHP version and server configuration.

Do not assume that a setting shown for the account’s home directory is necessarily the setting used by every domain. Select the correct domain when the interface offers domain-specific configuration. If you also need to change the PHP release assigned to a domain, see our guide to changing PHP versions in cPanel.

How to Enable PHP Short Tags on Your Hosting Account

Use the method supported by your hosting provider and PHP handler. Make a backup of existing configuration files before editing them. The directive is called short_open_tag, and the intended value is On.

Method 1: Use cPanel MultiPHP INI Editor

  1. Sign in to cPanel.
  2. Open Software → MultiPHP INI Editor.
  3. Select the domain you want to configure.
  4. Look for short_open_tag in Basic Mode. If it is not listed, check whether Editor Mode allows the directive for your PHP version.
  5. Set the directive to On, then apply or save the change.
  6. Recheck the active value using the temporary PHP script described above.

cPanel explains that MultiPHP INI Editor can save supported settings to the relevant PHP configuration files, which may include php.ini, .user.ini or .htaccess, depending on the server setup. The interface does not guarantee that every directive is supported in every environment. Read the cPanel MultiPHP INI Editor documentation for the options available on your server.

Method 2: Configure php.ini

If your hosting provider permits per-account or per-domain php.ini configuration, open the appropriate file in the domain’s configuration directory. Add or update this directive:

short_open_tag = On

Save the file and follow your host’s instructions for applying PHP configuration changes. On managed or shared hosting, you may not have permission to restart PHP services, and a restart may not be required. If the value does not change, confirm which configuration file the website’s PHP process actually loads.

For a deeper explanation of how PHP reads configuration files, see the PHP configuration file documentation.

Method 3: Use a .user.ini file with CGI or FastCGI PHP

PHP supports per-directory .user.ini files when PHP runs through CGI or FastCGI. In the relevant directory, create or edit a file named .user.ini and add:

short_open_tag = On

Save the file and allow for the configured user-INI cache interval before testing again. The default cache interval is commonly five minutes, but the server administrator can change it. This method does not apply to every PHP handler; PHP’s documentation specifies that .user.ini processing is for CGI/FastCGI SAPIs. See the PHP .user.ini guide.

Method 4: Use .htaccess where the PHP handler supports it

On an Apache server running PHP as an Apache module, a per-directory PHP setting may be accepted in .htaccess when the server configuration permits the relevant override. A typical directive is:

php_value short_open_tag On

This is not a universal solution. It may cause an HTTP 500 error when used with PHP-FPM, FastCGI or a configuration that does not allow PHP values in .htaccess. Some hosting configurations use handler-specific sections or a control panel to manage PHP values. If you are unsure which handler is active, do not add this line blindly. Ask your hosting provider which method is supported.

For more background, read our guide to what an .htaccess file does and how to use it.

Method 5: Use Plesk PHP Settings

On a Plesk server, open Websites & Domains, select the domain and open PHP Settings. If the hosting provider exposes the short_open_tag directive, change it to On and apply the settings. Some providers restrict which PHP directives customers can change, so the option may not be available.

Method 6: Ask your hosting provider

If the directive is not available in your control panel, or your configuration changes have no effect, contact your hosting provider. Tell support:

  • The domain and directory affected.
  • The PHP version selected for that domain.
  • The PHP handler, if known (for example, PHP-FPM or FastCGI).
  • That the legacy application requires short_open_tag.
  • Which configuration method you have already tried and what result you received.

Your provider can confirm whether the setting is permitted and apply it at the correct level if necessary.

Why the .htaccess Method May Not Work

The php_value directive is associated with Apache’s PHP module configuration. It is not accepted in every PHP execution mode. For example, a PHP-FPM or FastCGI setup may ignore or reject it in .htaccess. Depending on the configuration, the result may be an internal server error rather than a successful change.

If your website starts returning a 500 error immediately after adding the directive, remove the new line or restore your backup using File Manager or FTP. Then use the control panel or the configuration method recommended by your host. See our guide to fixing a 500 Internal Server Error if the problem persists.

Common Problems When Enabling PHP Short Tags

The setting still shows Off

You may have edited a configuration file that is not loaded by the website, selected the wrong domain, or used a method unsupported by the active PHP handler. Check the loaded configuration through the web PHP process and ask your provider to confirm the applicable configuration path. For command-line checks, see how to use the cPanel Terminal, keeping in mind that CLI PHP settings may differ from the website’s PHP configuration.

The website displays PHP code instead of running it

Confirm that the file is being processed by PHP and that the application is using the correct opening tag. Do not leave a diagnostic or source file publicly accessible. If the script relies on <?, check the active short_open_tag value.

The website returns a 500 error

An unsupported php_value directive or another invalid configuration line may be responsible. Restore the previous file, then use the PHP configuration interface supported by the host. Check the server error log for the exact cause. You can also follow our guide to enabling PHP error reporting on your hosting account when you need more diagnostic information.

The change works on one domain but not another

PHP settings can be configured per domain or directory. Check the PHP version and configuration for each domain separately, and confirm that the files are in the correct document root.

The setting works after a delay

Some PHP configurations cache per-directory settings. If you use .user.ini, allow for the configured cache interval before testing again. Do not repeatedly change the directive while waiting for the cache to refresh.

Should You Enable PHP Short Tags?

Enable the setting only when an application you need to maintain genuinely depends on the plain <? opening tag. If you control the source code, replacing those tags with <?php is generally the more portable long-term solution.

Do not enable the setting solely to use <?=, because that shorthand works independently of short_open_tag. Before changing a live site, back up its files, test on a staging copy where possible and check any XML output or templates that may contain XML declarations.

Shared Hosting with PHP Configuration Tools

If you manage PHP applications on shared hosting, check whether the plan provides cPanel or another control panel with per-domain PHP configuration. The availability of individual directives still depends on the PHP version, handler and server policy, so confirm support before relying on a particular setting.


Shared hosting plans with cPanel and PHP website support

Shared Hosting with cPanel

Explore shared hosting plans that include cPanel, PHP website support, databases, SSL and backup features.

Explore Shared Hosting

Frequently Asked Questions

What does short_open_tag do in PHP?

It controls whether PHP recognises the abbreviated opening tag <? as the start of a PHP code block.

Does short_open_tag affect the <?= echo tag?

No. The short echo tag <?= is available regardless of the short_open_tag setting in PHP 5.4 and later.

Can I enable PHP short tags in cPanel?

You may be able to enable the directive through MultiPHP INI Editor. Availability depends on the PHP version and the hosting provider’s server configuration.

Can I enable short tags using .htaccess?

Only on compatible Apache/PHP configurations that permit the directive. It is not a reliable method for every PHP-FPM or FastCGI setup.

Is it safe to enable PHP short tags?

The directive is primarily a compatibility setting, but short tags can conflict with XML declarations in PHP-parsed files. Use it only when required by legacy code and test the application carefully.

How do I disable PHP short tags again?

Set short_open_tag = Off using the same supported configuration method, then verify the value through the website’s PHP environment. Check that the application no longer relies on plain short opening tags before disabling it.

Conclusion

PHP short tags can help older applications continue to run, but the correct way to enable them depends on your PHP handler and hosting configuration. Start by checking the active setting, then use cPanel MultiPHP INI Editor, php.ini, .user.ini, Plesk or a provider-supported Apache configuration method.

For new development, use the full <?php opening tag and reserve short-tag activation for compatibility situations where it is genuinely necessary. Always back up configuration files, verify changes through the web PHP process and remove diagnostic scripts after testing.