tags:

views:

21

answers:

1

I really liked PHPs <?= $out ?> to echo something. In PHP 5.3 this is deprecated as we know.

So i thought about using something like that:

$_ = function($name) use ($tpl_vars) { echo $tpl_vars[$name]; }

In $tpl_vars all my template variables are stored.

Now i can use

<?php $_['name']; ?>

instead of:

<?php echo $tpl_vars['name']; ?>

to echo something.

What do you think about that?

A: 

I personally dislike shortcut functions because of the increased likelihood of collisions when using other libraries etc.

Other than that: Why not? I can't see anything inherently wrong with it.

Before closures, people have used global variables or static classes to the same effect.

Pekka