Re: [RFC Idea] Short echo tag with automatic HTML escaping (<?~ ... ?>)
| From: | Sergei Issaev | Date: | Wed, 24 Dec 2025 04:28:57 +0000 |
| Subject: | Re: [RFC Idea] Short echo tag with automatic HTML escaping (<?~ ... ?>) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129685@lists.php.net to get a copy of this message | ||
Hi Anton,
Thank you for the discussion!
- short_open_tag has been disabled by default since PHP 5.4 (2012).But there is no plan to remove them, see: https://wiki.php.net/rfc/deprecate_php_short_tags_v2 https://wiki.php.net/rfc/counterargument/deprecate_php_short_tags
<?= exists since forever and "= $expr" is not a valid code. You should at least choose another symbol (like "<?*").I agree: since short tags remain valid syntax, the parser and tooling must correctly handle them in all configuration states. Therefore, I propose replacing
<?~ ... ?> with <?: ... ?>.
See above, also respecting default_charset is a must imho, not everyone uses UTF-8, East Asia specifically. Introducing a core syntax and excluding a huge portion of users is not a good move.The semantics of
<?: $expr ?> would be equivalent to: `<?php echo htmlspecialchars($expr, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5); ?>` -- that is, the encoding will be determined automatically via the current default_charset setting, as htmlspecialchars() does by default.
Best regards,
Sergei Issaev