php: "short_open_tag = On" not working

php: "short_open_tag = On" not working

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

php: "short_open_tag = On" not working

When phpinfo() confirms that Apache is loading the correct configuration file, yet the short_open_tag directive appears as Off, the issue almost never lies with Apache itself. In a standard WAMP environment running PHP 5.4 on Windows, the culprit is usually one of three specific scenarios: a conflicting user-level configuration file, an incorrect syntax within your .ini entry, or a misunderstanding of how opcode caching interacts with short tags.

The most common pitfall in this scenario involves the priority of configuration files. While you may have edited C:\wamp\bin\php\php5.4.x\php.ini-production, Apache might be loading a different file entirely, or it might be loading that production file alongside a user-specific override that explicitly disables short tags.

To diagnose this, check the Loaded Configuration File and Scan this dir for additional .ini files sections in your phpinfo() output. If you see multiple paths listed under "Additional .ini Files," examine each one. A common mistake is placing settings into C:\wamp\bin\php\php5.4.x\extras\conf\php.ini-development. Sometimes, the development configuration file exists but is never loaded because it isn't referenced in the main production file or the Apache config. If your application relies on a specific .ini file found in the Scan this dir location, ensure that short_open_tag = Off isn't sitting there silently overriding your settings in the main file.

Even if you are certain you have edited the correct php.ini, syntax errors can prevent the directive from taking effect. The value must be exactly On. There is no space allowed before or after the equals sign, and it must be lowercase unless you are using a Windows registry key workaround (which is not recommended). Furthermore, ensure you haven't commented out the line with a semicolon at the end of that specific line. If you have multiple instances of short_open_tag in your configuration files, the last one read by PHP wins. This is often where confusion arises; editing an old file while using a newer version of WAMP can lead to stale configurations being ignored.

Another subtle issue involves opcode caching. If you are using APCu, OPcache, or Xdebug with their own specific configuration files located in the Scan this dir path, these files can override main php.ini settings. While less common for short_open_tag, it is a known behavior in complex setups where a user-defined cache configuration disables legacy features to enforce standard coding practices. If you have installed an opcode accelerator manually via a .ini file in the extra configuration folder, double-check that it doesn't contain a line setting short tags to off.

From a practical standpoint, relying on short_open_tag is generally discouraged in modern PHP development. These tags are legacy artifacts designed for older versions of PHP 3 and 4. They lack namespace awareness, which can lead to variable collision issues when using namespaces or classes with names that clash with global variables (e.g., $foo). The standard convention in the industry is to use <?php for all files and <?= only where absolutely necessary. If your codebase relies on short tags without closing them properly, switching back to long tags often resolves syntax errors immediately.

If you are migrating a legacy project that depends heavily on short tags, the most robust solution is not to fight the configuration but to enforce consistency. You can force all files to use <?php while keeping short_open_tag = Off in your configuration. This prevents accidental inclusion of global variables inside class scopes. If you must keep short_open_tag = On, ensure that your code strictly avoids using variables starting with $ unless they are intended to be global, or wrap them in a namespace to prevent collisions.

In the context of Laravel or modern PHP frameworks, short tags are often disabled by default for security and compatibility reasons. If you are attempting to run an older script that uses <?= inside a Blade template or a controller file, the framework will throw a parse error regardless of your php.ini settings if the tag is not recognized. In these cases, updating the syntax is the only viable path forward. For more details on configuring PHP environments for modern frameworks, you might find relevant documentation at https://laravelcompany.com regarding their specific setup guides and environment requirements.

Our network