Re: [RFC] New operator for context-dependent escaping
| From: | Ryan Pallas | Date: | Fri, 22 Jul 2016 13:44:07 +0000 |
| Subject: | Re: [RFC] New operator for context-dependent escaping | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-94630@lists.php.net to get a copy of this message | ||
On Fri, Jul 22, 2016 at 1:31 AM, Michael Vostrikov <
michael.vostrikov@gmail.com> wrote:
>
> > The trick with the magic class name and namespace aliasing is neat, but
> feels likely to confuse a lot of users
>
> Yes, I have to agree. Maybe more better way is to make it similar to
> set_error_handler() - not for context as it is in RFC, but for 'escape'
> callable.
>
> <?php
>
> // somewhere in application
>
> set_escape_handler(function($string, $context = 'html'){
> ...
> });
>
> // or
>
> set_escape_handler([$this, 'escape']);
> ?>
>
> <?* $myValue, $myContext ?>
>
Which begs the question, if you can verify that the call to
set_escape_handler comes before the template, then can you also be sure
that a function definition will come before it, and just call a function
directly?