3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php    class Animal {     public static $name = "animal";        // Return the class that is represented by "self::"     public function getSelfClass()     {         return get_class();     }        // Return the class that is represented by "static::"     public function getStaticClass()     {         return get_called_class();     }        public function selfVar()     {         return self::$name;     }        public function staticVar()     {         return static::$name;     }        public function selfMethod()     {         return self::getName();     }        public function staticMethod()     {         return static::getName();     }        protected function getName()     {         return "animal";     }    }    class Penguin extends Animal {     public static $name = "penguin";        protected function getName()     {         return "penguin";     } }    var_dump('selfVar'.Penguin::selfVar()); var_dump('staticVar'.Penguin::staticVar()); var_dump('selfMethod'.Penguin::selfMethod()); var_dump('staticMethod'.Penguin::staticMethod()); var_dump('getSelfClass'.Penguin::getSelfClass()); var_dump('getStaticClass'.Penguin::getStaticClass());
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/qm9On on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_CLASS in /in/qm9On on line 4
Process exited with code 255.