PHP curly brace syntax for member variable

Curly braces are used to explicitly specify the end of a variable name. For example:

echo "This square is {$square->width}00 centimeters broad."; 

So, your case is really a combination of two special cases. You’re allowed to access class variables using curly braces and like so:

$class->{'variable_name'} // Same as $class->variable_name
$class->{'variable' . '_name'} // Dynamic values are also allowed

And in your case, you’re just surrounding them with the curly brace syntax.

See the PHP manual, “complex (curly) syntax.”

Leave a Comment