Re: [RFC Idea] Short echo tag with automatic HTML escaping (<?~ ... ?>)

From: Date: Tue, 23 Dec 2025 10:07:37 +0000
Subject: Re: [RFC Idea] Short echo tag with automatic HTML escaping (<?~ ... ?>)
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-129675@lists.php.net to get a copy of this message
Hi! On 23/12/2025 11:06, Sergei Issaev wrote:
which compiles to:
<?php echo htmlspecialchars($expr, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8'); ?>
htmlspecialchars is configurable for a reason and your flags are arbitrarily different from the function default
- Syntax is currently a parse error → no BC break.
It's not, you forgot about short_open_tag=1, in which case it's interpreted as <? (~$expr) ?> I basically see no value over // included earlier function h($s) { return htmlspecialchars($s, ENT_QUOTES | ENT_HTML5, 'UTF-8'); } // template <?= h($user_input) ?> It's short, it does what you want, it's available today -- Anton

« previous php.internals (#129675) next »