3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Stringable { public function __toString() { return "A"; } } //var_dump(preg_replace('#A#si','B',$x=new Stringable())); $a=new SplObjectStorage(); $a[new DateInterval('1y')]=7; echo(serialize($a));
based on GleJp
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Exception: DateInterval::__construct(): Unknown or bad format (1y) in /in/keLcS:12 Stack trace: #0 /in/keLcS(12): DateInterval->__construct('1y') #1 {main} thrown in /in/keLcS on line 12
Process exited with code 255.
Output for 5.3.18 - 5.6.28
Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (1y)' in /in/keLcS:12 Stack trace: #0 /in/keLcS(12): DateInterval->__construct('1y') #1 {main} thrown in /in/keLcS on line 12
Process exited with code 255.