3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $c = new SplObjectStorage (); // You store some data using some string keys foreach (array('ab', 'cd', '10', 'gh', '24') as $key) { $c[(string)"$key"] = 1; } // You pass the array $c to some place else and there you do something like foreach ($c as $k => $v) { if ($k === "10") { echo "found"; exit; } }
based on 08fup
Output for 5.3.0 - 7.2.0
Warning: SplObjectStorage::offsetSet() expects parameter 1 to be object, string given in /in/j8MZQ on line 7 Warning: SplObjectStorage::offsetSet() expects parameter 1 to be object, string given in /in/j8MZQ on line 7 Warning: SplObjectStorage::offsetSet() expects parameter 1 to be object, string given in /in/j8MZQ on line 7 Warning: SplObjectStorage::offsetSet() expects parameter 1 to be object, string given in /in/j8MZQ on line 7 Warning: SplObjectStorage::offsetSet() expects parameter 1 to be object, string given in /in/j8MZQ on line 7
Output for 5.1.0 - 5.2.17
Fatal error: Cannot use object of type SplObjectStorage as array in /in/j8MZQ on line 7
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Class 'SplObjectStorage' not found in /in/j8MZQ on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: splobjectstorage in /in/j8MZQ on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: splobjectstorage in /in/j8MZQ on line 3