3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace test\foo; class Bar { public static function className() { $class = self; return (new \ReflectionClass($class))->getShortName(); } } echo \test\foo\Bar::className(), PHP_EOL;
based on iMjid
Output for 7.2.0
Warning: Use of undefined constant self - assumed 'self' (this will throw an Error in a future version of PHP) in /in/QGbjE on line 5 Fatal error: Uncaught ReflectionException: Class self does not exist in /in/QGbjE:6 Stack trace: #0 /in/QGbjE(6): ReflectionClass->__construct('self') #1 /in/QGbjE(10): test\foo\Bar::className() #2 {main} thrown in /in/QGbjE on line 6
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Notice: Use of undefined constant self - assumed 'self' in /in/QGbjE on line 5 Fatal error: Uncaught ReflectionException: Class self does not exist in /in/QGbjE:6 Stack trace: #0 /in/QGbjE(6): ReflectionClass->__construct('self') #1 /in/QGbjE(10): test\foo\Bar::className() #2 {main} thrown in /in/QGbjE on line 6
Process exited with code 255.
Output for 5.4.1 - 5.6.28
Notice: Use of undefined constant self - assumed 'self' in /in/QGbjE on line 5 Fatal error: Uncaught exception 'ReflectionException' with message 'Class self does not exist' in /in/QGbjE:6 Stack trace: #0 /in/QGbjE(6): ReflectionClass->__construct('self') #1 /in/QGbjE(10): test\foo\Bar::className() #2 {main} thrown in /in/QGbjE on line 6
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/QGbjE on line 6
Process exited with code 255.