Well, to fully understand the somewhat weird look $object->$foo, you need to understand two things about PHP:
Variable names
Most time variables in PHP are pretty straight forward. They start with a character $, have one character [a-zA-Z_], and then any number of characters [a-z-A-Z0-9_]. Examples include:
$var = 'Abcdef';
$_GET = [];
$a1 = 123;
PHP , , , , , - ({}), :
${null} = 'It works'; echo ${null};
${false} = 'It works'; echo ${false};
${'!'} = 'It works'; echo ${'!'};
// Slightly weirder...
${(int)trim(' 5 ')} = 'It works'; echo ${5};
${implode(['a','b','c'])} = 'It works'; echo $abc;
: , , , . PHP, .
: - , .
- , PHP. :
${"abc"} = 'Abc...';
echo $abc;
"abc", , $abc.
( ), , ... :
$abc = 'Abc...';
$varName = 'abc';
echo ${$varName}; // echo $abc
. "" :
$abc = 'Abc...';
$varName = 'abc';
echo $$varName; // echo $abc
$object->$foo " ",
$object = new stdClass;
$object->abc = 'The alphabet!';
$foo = 'abc';
echo $object->$foo;
echo $object->{$foo};
echo $object->{'abc'};
, . .