3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Msg { var $x = array(); function __construct() { echo "CONSTRUCTOR CALLED\r\n"; } function testStaticSet() { Msg::setValue("ERROR", 'HELLO!'); } function setValue($name, $value) { if(!isset($this)) { echo "called static outside of class!\n"; return false; } $this->x[$name] = $value; } function getValue($name) { if(!isset($this)) { echo "called static outside of class!\n"; return false; } return $this->x[$name]; } } Msg::setValue("ERROR", 'Hello World!'); echo Msg::getValue("ERROR"); $a = new Msg(); $a->testStaticSet(); echo $a->getValue("ERROR");
based on N74fR
Output for 7.0.0 - 7.2.0
Deprecated: Non-static method Msg::setValue() should not be called statically in /in/YsJdX on line 30 called static outside of class! Deprecated: Non-static method Msg::getValue() should not be called statically in /in/YsJdX on line 31 called static outside of class! CONSTRUCTOR CALLED HELLO!
Output for 5.3.21 - 5.6.28
Strict Standards: Non-static method Msg::setValue() should not be called statically in /in/YsJdX on line 30 called static outside of class! Strict Standards: Non-static method Msg::getValue() should not be called statically in /in/YsJdX on line 31 called static outside of class! CONSTRUCTOR CALLED HELLO!