Skip to content

Instantly share code, notes, and snippets.

@antonmedv
Created February 25, 2015 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonmedv/5731f7af534d289c9878 to your computer and use it in GitHub Desktop.
Save antonmedv/5731f7af534d289c9878 to your computer and use it in GitHub Desktop.
We need to go deeper.
<?php
$dream = 'Unicorn';
${'3 level'} = 'dream';
${'2 level'} = '3 level';
${'1 level'} = '2 level';
$DiCaprio = '1 level';
echo $$$$$DiCaprio;
// http://3v4l.org/RiB8b
@rybakit
Copy link

rybakit commented Dec 8, 2016

https://3v4l.org/n0aKX

$n = 1000;

for ($i = 1; $i < $n; $i++) {
    ${"$i level"} = ($i + 1).' level';
}

$dream = 'Unicorn';
${"$n level"} = 'dream';
$DiCaprio = '1 level';

$result = str_repeat('$', $n + 2).'DiCaprio';
printf("%s = '%s';", $result, eval("return $result;"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment