NYCPHP Meetup

NYPHP.org

[nycphp-talk] Short Tags deprecated?

John Campbell jcampbell1 at gmail.com
Sat Aug 29 15:14:34 EDT 2009


On Sat, Aug 29, 2009 at 5:07 AM, Justin
Hileman<justin at justinhileman.info> wrote:
>
> For bonus points, I'm a fan of something this:
>
> function _($string) { echo htmlspecialchars(l10n($string)); }
>

Be careful... _() is already defined as an alias for gettext()

I have a feeling that would cause a ton of compatibility issues.  Some
time ago, I looked at the magento source code, and they were using
__(), which seems like a reasonable alternative.

When internationalizing an app, you often need to write code like:

printf(l10n('<b>%s</b> wants to be your friend'),
htmlspecialchars($friend_name) );

It is handy to make your shortcut behave like printf when there is
more than 1 argument.

-John Campbell



More information about the talk mailing list