by wvenable · 7y ago · 0 comments
Although PHP does support the above syntax, it's actually pretty rare in production code. PHP can be optimized like JavaScript is: perform direct variable/member access but provide a slow path for these kinds of dynamic lookups.
<?php
eval('class Hello {public static function you(){echo "Yes!";}}');
Hello::you();
or this: <?php
file_put_contents('c.php', '<?php class Hello {public static function you(){echo "Yes!";}}');
require('c.php');
Hello::you();
Thus generating a class at runtime-ish.