3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Msg { var $x = array(); function a() { 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 EMmdm
Output for 7.0.0 - 7.2.0
Deprecated: Non-static method Msg::setValue() should not be called statically in /in/N74fR on line 30 called static outside of class! Deprecated: Non-static method Msg::getValue() should not be called statically in /in/N74fR on line 31 called static outside of class! HELLO!
Output for 5.1.3 - 5.6.28
Strict Standards: Non-static method Msg::setValue() should not be called statically in /in/N74fR on line 30 called static outside of class! Strict Standards: Non-static method Msg::getValue() should not be called statically in /in/N74fR on line 31 called static outside of class! HELLO!
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/N74fR on line 3 Strict Standards: Non-static method Msg::setValue() should not be called statically in /in/N74fR on line 30 called static outside of class! Strict Standards: Non-static method Msg::getValue() should not be called statically in /in/N74fR on line 31 called static outside of class! HELLO!
Output for 4.3.0 - 4.4.9
called static outside of class! called static outside of class! HELLO!