3v4l.org

run code in 300+ PHP versions simultaneously
<?php $great = 'abc'; ${'great '} = 'def'; const great = 'ghi'; $ghi = '...'; ${"ෝ"} = 'Meh'; // ${\u{ddd}} = 'Meh'; var_dump("${great }"); // outputs the constant value's variable value var_dump("${'great '}"); // outputs the ${'great '} variable value var_dump("${great}"); // outputs the $great variable value var_dump("${'ෝ'}"); // outputs the ${\u{ddd}} variable value var_dump("${ෝ}"); // outputs the ${\u{ddd}} variable value /* Even though "great " is not a valid variable name, neither is "\u{ddd}" but that still works. I'd therefore expect "${great }" to firstly search for a variable named "great " before falling back to evaluating the expression first. */

preferences:
30.16 ms | 402 KiB | 5 Q