3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { public function __construct() { echo 'Constructing MyClass'."\n"; } } $className = 'MyClass'; $objFromString = new $className(); var_dump($objFromString);

preferences:
24.16 ms | 404 KiB | 5 Q