NYCPHP Meetup

NYPHP.org

[nycphp-talk] Variable composition: ${'foo'.$i}

Jerry B. Altzman jbaltz at altzman.com
Thu Jan 30 12:12:14 EST 2014


on 1/29/2014 12:07 PM Ron Guerin said the following:
> On 01/27/2014 09:44 PM, justin wrote:
>> http://www.reddit.com/r/programming/comments/dst56/today_i_learned_about_php_variable_variables/c12np38
> Wow.  That's some scary stuff there.

Yet, you can do the same sort of Stupid Language Tricks in Python and 
Perl as well. (LISP macros also come to mind.) PHP isn't alone in this 
regard. I think the problem in the article really hinges on the 
inconsistencies in interpretation of string constants, etc.

'Variable variables' aren't pure evil; they just provide a level of 
indirection that allows for fine-grained loss of control at runtime. 
They're also nastier to debug. Any language that has an 'eval' function 
or allows you to dynamically control the interpreter (or compiler) will 
give you this.

> - Ron

//jbaltz
-- 
jerry b. altzman | jbaltz at altzman.com | www.jbaltz.com | twitter:@lorvax
thank you for contributing to the heat death of the universe.


More information about the talk mailing list