3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class container { protected $storage=array(); public function add(test1 $obj) { if(!isset($this->storage[spl_object_hash($obj)])) { $this->storage[spl_object_hash($obj)]=$obj; } } } class test1 { public function __construct($s) { } } $o=new container(); $o->add(new test1("lalala")); // will be added $o->add(new test1("lololo")); // not added - NOT as expected $t=new test("lalala"); $o=new container(); $o->add($t); // will be added $o->add($t); // not added - as expected var_dump($o);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Class 'test' not found in /in/rKrng:19 Stack trace: #0 {main} thrown in /in/rKrng on line 19
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: Class undefined: test in /in/rKrng on line 19
Process exited with code 255.
Output for 5.3.28 - 5.3.29, 5.4.20 - 5.6.28
Fatal error: Class 'test' not found in /in/rKrng on line 19
Process exited with code 255.
Output for 5.2.0 - 5.3.27, 5.4.0 - 5.4.19
Fatal error: Class 'test' not found in /in/BHaNW on line 19
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function spl_object_hash() in /in/BHaNW on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/BHaNW on line 3
Process exited with code 255.
Output for 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/BHaNW on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/BHaNW on line 3
Process exited with code 255.
Output for 4.3.0
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/rKrng on line 3
Process exited with code 255.