On Thu, Jan 30, 2014 at 12:12 PM, Jerry B. Altzman <jba...@altzman.com>wrote:

>
> 'Variable variables' aren't pure evil; they just provide a level of
> indirection that allows for fine-grained loss of control at runtime.
>

Not only are they not evil, they're necessary for a lot of Don't Repeat
Yourself optimizations.

I use this pattern all the time:

foreach( array('pages', 'posts', 'comments') AS $collection ) {
  ${$collection} = $model->load( $collection );
  // do more stuff with ${$collection} here
  $template->assign( ${$collection}, $collection );
}

It's a little bit harder to read until you get used to it, but because it's
DRY it's much easier to manage over time.
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show-participation

Reply via email to