NYCPHP Meetup

[nycphp-talk] Short Tags deprecated?

Hans Zaunere lists at zaunere.com
Sat Aug 29 18:21:50 EDT 2009


> > Absolutely, some type of shorthand is needed, which is exactly why they
> > exist in the first place.  I think the issue with removing <?= was that
no
> > one could decide what to actually replace it with.  It'll come, wait for
> > it...
>
> Well you're at it,  how about a version of <?= that has
> htmlspecialchars() built in...
> 
> It might be an irresponsible namespace grab,  but I've got a
> function that is (almost)
> 
> function Q($s) { echo htmlspecialchars($s) };
> 
> and I get into the habit of writing <?php Q($string) ?> in my
> templates so I'm not writing hundreds of HTML injection bugs all day..

Yeah something like this could be handy, certainly.  I typically push/adapt
an object into the template which is property overloaded.  Then something
like:

<?=$Object->FirstName?>

Outputs correctly escaped (or processed in any other way depending on what
the overload wants to do) content.  Quite handy and has proved effective.

It does seem that it'd be handy to have some type of "stdout" processing
hook that can be overridden, while providing a shorthand for working in
templates.

Hmm... streams... wonder if that could do anything here as they are now...
I'll have to look it up.

H





More information about the talk mailing list