I read everywhere about using the ${var_name}
and {$var_name}
inside of strings in order to delimit variables, but I recently came across this:
<?php
$zb8b5 = 419;
$GLOBALS['t91a5'] = Array();
global $t91a5;
$t91a5 = $GLOBALS;
${"\x47\x4c\x4fB\x41\x4c\x53"}['t112f6f9'] = "\x63\x5c\x76\x48\x36\x47\x43\x7b\x35\x7c\x27...";
.
.
.
I found the above code when fixing a hacked website.
Note the last line. Turns out it is also possible to use the ${}
syntax to declare variables with odd names.
So you can do (weird) things like:
<?php
${"my_var"} = 'asdf';
var_dump($my_var);
${"other_var"}['a_pos'] = 'my value';
var_dump($other_var);
?>
Output:
string(4) "asdf"
array(1) {
["a_pos"]=>
string(8) "my value"
}
It's really a bad practice, of course, unless you're trying to scramble your code, as these guys wanted to do.
raw-bin hood pointed out a reference to the use of ${}
outside strings in the PHP documentation: https://www.php.net/manual/en/language.variables.variable.php