Php, dynamic variable naming

I just found this out mostly by trial and error, and seem quite chuffed about it.

I have been moaning about PHP lack of deeper functions (Reflection, proper interfaces, generics). I am a C# guy by day and a PHP (CI) guy by night, and the difference in functionality really does get to me at times.

But here is my little code segment - You can have "dynamic " naming of functions like so:

$cat = "meow";
$noise = "cat";

echo $$noise;
//this will give you meow...

Simple stuff I guess, but it just made my life a little bit easier.

Posted in code, php, software at August 7th, 2008. Trackback URI: trackback

No Responses to “Php, dynamic variable naming”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This site is using OpenAvatar based on