3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Another{} namespace My\Full\Classname; class Another{} namespace Waa; use My\Full\Classname as Another; $obj = new Another; // instantiates object of class My\Full\Classname $a = 'Another'; $obj = new $a; // instantiates object of class Another ?>
Output for 7.0.1 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in /in/3a0Kd on line 5
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Class 'My\Full\Classname' not found in /in/3a0Kd:12 Stack trace: #0 {main} thrown in /in/3a0Kd on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0
Fatal error: Namespace declaration statement has to be the very first statement in the script in /in/3a0Kd on line 5
Process exited with code 255.

preferences:
257.15 ms | 402 KiB | 407 Q