Short Open Tag (<?)
debt(d3/e3/b3/t7)
Closest to 'default linter catches the common case' (d3). The detection_hints list phpcs, php-cs-fixer, and rector — all standard PHP toolchain tools that catch short open tags automatically. phpcs with PSR-1 ruleset and php-cs-fixer are commonly run in CI by default in PHP projects, making this effectively caught at the linter level.
Closest to 'simple parameterised fix' (e3). The quick_fix indicates replacing <? with <?php throughout the codebase, which is a pattern-level substitution. Tools like Rector's ShortOpenTagSniff and php-cs-fixer can automate this, but it may touch multiple template/PHP files. Not a single-line patch (e1), but not a deep architectural refactor either — it's a find-and-replace pattern across files within one codebase.
Closest to 'localised tax' (b3). Short open tags are a per-file syntactic choice. The burden is real — any file using <? is a latent compatibility hazard — but the issue is localised to the files that use them and doesn't impose a structural tax on the whole system's architecture. It doesn't shape every downstream decision the way a framework or ORM choice would.
Closest to 'serious trap' (t7). The misconception field states directly: 'Short tags work everywhere because my dev machine has them enabled — production servers, Docker images, and shared hosts commonly disable short_open_tag; code that depends on it fails silently or with parse errors.' This contradicts a reasonable developer assumption (it works locally, so it works everywhere). The failure mode described in why_it_matters — PHP source code including credentials served as raw text — makes this a serious trap rather than a minor edge case, scoring t7.
Also Known As
TL;DR
Explanation
PHP supports three open tags: <?php (always works), <?= (short echo, always works since PHP 5.4), and <? (short open tag, requires short_open_tag=On in php.ini). The <? short tag conflicts with XML processing instructions <?xml and is disabled in many shared hosting environments, Docker images, and production configurations. PSR-1 mandates only <?php and <?= tags. Rector can automatically expand <? to <?php across a codebase.
Common Misconception
Why It Matters
Common Mistakes
- Using <? throughout a legacy codebase that runs fine locally but fails on the production server.
- <?= is a short echo tag — unlike <?, this is always available since PHP 5.4 and is PSR-1 compliant.
- Mixing <?php and <? in the same file.
- Not running Rector's ShortOpenTagSniff to find all occurrences automatically.
Code Examples
<? // Short tag — requires short_open_tag=On
$user = getUser($id);
?>
<p>Hello <? echo $user->name; ?></p>
<? if ($user->isAdmin()): ?>
<p>Admin panel</p>
<? endif; ?>
<?php // Always works — PSR-1 compliant
$user = getUser($id);
?>
<p>Hello <?= htmlspecialchars($user->name) ?></p>
<?php if ($user->isAdmin()): ?>
<p>Admin panel</p>
<?php endif; ?>