To increase @ hakre's answer, you can also lose quotation marks for brevity
${1}
but alas, you cannot combine this with a string value. I did some experiments, and apparently, PHP expects either a string or a numeric value. And you can do something in curly braces that end up returning a number or a string value or implicitly passed either.
<?php
function eight (){
return 8;
}
${7+'fr'} = ${7*'fr'+1} = ${'hi'.((string)8).'hi'} = ${7.8910} = ${eight()} = ${(eight()==true)+4} = 'hi';
var_dump(get_defined_vars());
Outputs
array(8) { ["_GET"]=> array(0) { }
["_POST"]=> array(0) { }
["_COOKIE"]=> array(0) { }
["_FILES"]=> array(0) { }
["7.891"]=> string(2) "hi"
["7"]=> string(2) "hi"
["1"]=> string(2) "hi"
["hi8hi"]=> string(2) "hi"
["8"]=> string(2) "hi"
["5"]=> string(2) "hi" }
Addtionally I found something interesting:
<?php
${false} = 'hi';
${true} = 'bye';
var_dump(get_defined_vars());
Outputs
array(6) { ["_GET"]=> array(0) { }
["_POST"]=> array(0) { }
["_COOKIE"]=> array(0) { }
[""]=> string(2) "hi"
["1"]=> string(3) "bye" }
This means that it falseevaluates an empty string, not 0 and trueup to 1.
source
share