In PHP, variables usually have a pattern to follow in their declaration.
According to the manual:
Variables in PHP are represented by a dollar sign ($) followed by variable name. The variable names in PHP distinguish between uppercase and lowercase letters.
Variable names follow the same rules as other labels in the PHP. A valid variable name starts with a letter or underline, followed by any number of letters, digits or underscores.
However, I noticed that it is possible to "escape" this rule when defining the name of a variable.
Examples:
${1} = 1; // valor com número ${'1 variavel'} = 'número iniciando'; ${'Nome com espaço'} = 'Wallace'; ${'***Testando***'}[0][] = 'Array Louco';
Result:
Array ( [1] => 1 [1 variavel] => número iniciando [Nome com espaço] => Wallace [***Testando***] => Array ( [0] => Array ( [0] => Array Louco ) ) )
In addition to the variables being declared so, it is also possible (I think from PHP 5.4) to make the methods "run away" a little bit from their default.
class Teste { public function __call($method, $arguments) { echo "Método numérico [$method]"; } public static function __callStatic($method, $arguments) { echo "Método númérico estático [$method]"; } } Teste::{'10'}(); // Método numérico estático [10] $teste = new Teste; $teste->{'10'}(); // Método numérico
After all, what is the purpose of the variables being declared between braces?
Is there any case that this is useful?