3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Test { var $test = true; function isTest($test_flag = null){ if(func_num_args()){ $this->test = !!$test_flag; return $this; } return $this->test; } } $t = new Test; var_dump($t->isTest()); var_dump($t->isTest(false)); var_dump($t->isTest()); var_dump($t->isTest(true)); var_dump($t->isTest()); var_dump($t->isTest(null)); var_dump($t->isTest());
Output for 5.1.3 - 7.1.0
bool(true) object(Test)#1 (1) { ["test"]=> bool(false) } bool(false) object(Test)#1 (1) { ["test"]=> bool(true) } bool(true) object(Test)#1 (1) { ["test"]=> bool(false) } bool(false)
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/6LOTd on line 3 bool(true) object(Test)#1 (1) { ["test"]=> bool(false) } bool(false) object(Test)#1 (1) { ["test"]=> bool(true) } bool(true) object(Test)#1 (1) { ["test"]=> bool(false) } bool(false)
Output for 4.3.0 - 4.4.9
bool(true) object(test)(1) { ["test"]=> bool(false) } bool(false) object(test)(1) { ["test"]=> bool(true) } bool(true) object(test)(1) { ["test"]=> bool(false) } bool(false)