Re: New escaped output operator
| From: | Rasmus Schultz | Date: | Mon, 20 Jun 2016 15:24:50 +0000 |
| Subject: | Re: New escaped output operator | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-94150@lists.php.net to get a copy of this message | ||
> <ul>
> <?php foreach ( $things as $thing ) { ?>
> <li><a href="/things/<?= $thing['name'] ?>"
> onclick="show_popup('<?=
> $thing['name'] ?>');"><?= $thing['name'] ?></a>
> <?php } ?>
> </ul>
>
> There are three different escape mechanism needed there; if there is a
> shorthand for one, do you think it will be more likely or less that people
> will get the other two right?
I have to agree with that - assigning special syntax to one kind of
escape-function gives that function an elevated status, which could
easily encourage neglect and oversight.
I do wish that we had an obvious, consistently-named set of
web-related escape/encode functions for use in plain PHP templates,
like html(), attr(), js(), etc... having to type and read
htmlspecialchars() and json_encode() while you're trying to visually
parse a template is really inconvenient.
That's all it is though, inconvenience. Nice to have, not must have.
I'd be much more interested in a general solution to the problem of
being unable to (or at least strongly demotivated from) using actual
namespaced functions in this and many other cases - that's a missing
feature and a more general problem, whereas in my opinion an operator
or shorter function-names are just a work-around...
(and please, nobody say "use a template engine" - I *am* using a
template engine, it's called PHP!)