PHP VarVar $$ $hey = 'Life'; $b = 'hey'; echo $$b; PHP: 1. Think of it this way: Make $b's value a variable 2. So $b is 'hey', so it becomes $hey One you have to think about! $dog = 'yeah'; $a = array('dog', 2, 3); echo $$a[0]; PHP: 1. First get $a[0], that would be 'dog'. 2. Then, the variable becomes $dog 3. Then the value output is 'yeah' Whats this do? FUNCTION TEST() { ECHO "HELLO"; } test(); PHP: Surpisingly this works, because function names must be unique. Gets even more confusing $DOG = 1; $dog = 2; PHP: These are actually DIFFERENT! But above you see the casing for functions does not matter, but for variables it does! Know your arrays! $array = array(1 => 2, NULL => 3); echo count($array); PHP: It only returns 1 -- because NULL is not a key! What about this?? $ey = array(12 => 5, 1 => 10); $ey[] = 'Hey'!; PHP: What will the key be for the value we input? It is NOT going to be 2! Even though there is no 2 value, and 2 comes after 1, any value you add without a key will automatically increment from the highest key value. Okay, now youre confused!!! $str = 'hey\\a'; echo $str; PHP: What will that ouput? It will give you 'hey\a', because EVEN THOUGH we have a single quoted string (That doesnt parse $values), this is a special case that produces ONE \. You'll also find this in XML -> xpath! Thats all for now!
Tricky code is not something any programmer worth his salt should aim for. Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex.
I agree with Deacalion, simple is the best way to go, because when you get a mountain of code, if it looks foreign when you come to look back at it, its gonna be a nightmare to work out bugs. But then again, sometimes you need these complex solutions to be able to achieve the desired result