Re: New operator for htmlspecialchars

From: Date: Tue, 15 Jan 2013 22:24:38 +0000
Subject: Re: New operator for htmlspecialchars
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-64979@lists.php.net to get a copy of this message
On 16/01/13 08:22, Thomas Bley wrote:
Hello, I created a small ticket to propose a shorter syntax for htmlspecialchars: old: <?= htmlspecialchars($str, ENT_QUOTES) ?> new: <?+ $str ?> or: <?~ $str ?> any comments, pros and cons? https://bugs.php.net/bug.php?id=62574 Best regards, Thomas
The problem here is that htmlspecialchars only covers html body, and not html attributes, or other contexts (eg js, css, urls). You're better off using something like Zend\Escaper, or Symfony's escaper. The escaper RFC also gives a good amount of detail: https://wiki.php.net/rfc/escaper As for the shorter syntax with automatic output, I think it makes the code harder to read. Cheers, David

« previous php.internals (#64979) next »