3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if(version_compare(PHP_VERSION,'5.3.0','<')) exit; file_put_contents('/tmp/test.php', gzuncompress(base64_decode('eNrtWGtv2zYU/b5fwQBEKKGyq3ht2lkQOjd11wJNGtTGgLUuBEaibCUSKZNU3cTTf9/Vw/IzRpZ9GLrZsC2LOjw899xL0dRxrJ1X6ST9idOEqZT6DH1mPBgNdBBHV06mGHpDNRtGCfssOHP8mCrVNCH2XQNajRYN8zS7iiMfhRn3dSQ48jxfcKVl5msD+y7hYkasVUaEA5dncWzOo9D4xqSCXtAnSalkxuW7S+/3/qfB+48XFnne/rn9gljkeKwdl5jmXDKdSY4KJNfd7vpQFg5MJwfOI2iK4FO0EVCviXlMk9Qpv9YuhpEsrpZKoPdD+Fms2H4cgPKabxegMmTJdS8GADhsFbErpgvzlIYADIBooeG0lFQBxqsA0zSdWiAOnXwzP4kIovDWwON/7v+SasP38T7fxyu+7yHEE3cl1PE9oTqF0xPXdUMKZjaE5dlu//BkzZ68qu/ye1GlQ4DOUyk08zULEI7KenU2nQTaDDTMtyzWjMpAzLhRFVYlQjLwWg/vzHkAw3gBC2kWa68I7w5mhQdsW1Bno6HSkedLbati3lSUwzsDX5cjH20Nvcm3Wwp4bEAG9ui8Np0dUSv9Ohufdl7+ckp5cNp5fnpiNEOu6SO/nQ+hvvG1y9ls7XZjkH4mRcqevmYyjngBulkDGeRX0l4WBunYJ52W/bLV6SDb7pZvdNYfAH3jHmQWou1PMyiKlQ4nqNOpO4CcJza8kCHCEJQi24QpelP2DoVMKEzJP1pJK0DvulFXIWBvkwZM2jUUfPtYNhlm+3iaCe2Y1cEitY1I36FIoV6iNJMBTSxUmIxCKRKkFyVqIS7Qwm8L0RCw6IkN0FtVGlIOVs8VsnLhPxru4/N/szr9C/qycvf7tMHThP2iY//LNs0iPWmMenwh/CABPqAS7s299cOlmaJifeTjv5Pl/58dO2pi1+rSUxF9OmAiiw+LzGGROSwyh0XmsMgcFpnHLzK79ltrIeLYwomF+fK5Bo6PXJyYcz2RYobAwlH/u8/SoqthYP4K81rwiFfHbnWoo1hcrA44rn+gIxct2pLROkHx2CHHokjX6BMLY1bqPCv2tYbnXfTO+4PL3lnf89pktLXbhSDBdkb9iYHFwtpzpiciUIZJFcJpGZbKrso9fLrADCZC6gsKlWFatvXMPHJdoktCX3Ad8Yw5Wt7O8bQso61xYZuJp4v7Z7GZdmrqiH8TN3AnnTaA5abayX2qQenSUoSlOWf+RCDytvf+Q7eokF0SHaxcLJvnCJL6RWPVEf2J4L8AK7qqL/bXL6Q4I1830lSBlxznTCk6Zk39Nbgq6ocpzxuv8krLZW8wuDeIzZHyvwDNSVvD'))); include '/tmp/test.php';
Output for 5.3.0 - 7.1.0
&lt;?php namespace Zend\Stdlib;use DateTimeZone;class DateTime extends\DateTime{public function __construct($c='now',DateTimeZone $d=null){if(version_compare(PHP_VERSION,'5.3.7','&gt;=')){return parent::__construct($c,$d);}if(!stristr($c,'last')&amp;&amp;!stristr($c,'first')){if($d){return parent::__construct($c,$d);}else{return parent::__construct($c);}}if($d){parent::__construct('now',$d);}else{parent::__construct('now');}$f-&gt;setTimestamp(strtotime($c,$f-&gt;getTimestamp()));return $f;}public function modify($g){if(version_compare(PHP_VERSION,'5.3.7','&gt;=')){return parent::modify($g);}if(!stristr($g,'last')&amp;&amp;!stristr($g,'first')){return parent::modify($g);}$h=strtotime($g,$f-&gt;getTimestamp());if($h===false){return false;}$f-&gt;setTimestamp($h);return $f;}}class classDateTimeTest{protected $i=null;public function setup(){}public function teardown(){if($f-&gt;revertTz){date_default_timezone_set($f-&gt;revertTz);$f-&gt;revertTz=null;}}protected function setDefaultTz($j){if(!$f-&gt;revertTz){$f-&gt;revertTz=date_default_timezone_get();}date_default_timezone_set($j);}public function testBug62896and62561(){$f-&gt;setDefaultTz('GMT');$j=new DateTimeZone('Europe/Berlin');$k=new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST'));$f-&gt;assertEquals('2012-08-21 22:00:00 GMT+0000 (offset 0)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from timestamp, no timezone, after +0 days');$k-&gt;modify('+0 days');$f-&gt;assertEquals('2012-08-21 22:00:00 GMT+0000 (offset 0)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from timestamp, no timezone, after +0 days');$k=new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST'));$k-&gt;setTimezone($j);$f-&gt;assertEquals('2012-08-22 00:00:00 CEST (offset 7200)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from timestamp, with timezone');$k-&gt;modify('+0 days');$f-&gt;assertEquals('2012-08-22 00:00:00 CEST (offset 7200)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from timestamp, with timezone, after +0 days');$k=new DateTime('2012-08-22 00:00:00 CEST',$j);$f-&gt;assertEquals('2012-08-22 00:00:00 CEST (offset 7200)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from a string, with timezone');$k-&gt;modify('+0 days');$k=new DateTime('2012-08-22 00:00:00 CEST',$j);$f-&gt;assertEquals('2012-08-22 00:00:00 CEST (offset 7200)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from a string, with timezone, after +0 days');$f-&gt;setDefaultTz('Asia/Seoul');$j=new DateTimeZone('Europe/Berlin');$k=new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST'));$f-&gt;assertEquals('2012-08-21 22:00:00 GMT+0000 (offset 0)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from timestamp, no timezone, after +0 days');$k-&gt;modify('+0 days');$f-&gt;assertEquals('2012-08-21 22:00:00 GMT+0000 (offset 0)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from timestamp, no timezone, after +0 days');$k=new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST'));$k-&gt;setTimezone($j);$f-&gt;assertEquals('2012-08-22 00:00:00 CEST (offset 7200)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from timestamp, with timezone');$k-&gt;modify('+0 days');$f-&gt;assertEquals('2012-08-22 00:00:00 CEST (offset 7200)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from timestamp, with timezone, after +0 days');$k=new DateTime('2012-08-22 00:00:00 CEST',$j);$f-&gt;assertEquals('2012-08-22 00:00:00 CEST (offset 7200)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from a string, with timezone');$k-&gt;modify('+0 days');$k=new DateTime('2012-08-22 00:00:00 CEST',$j);$f-&gt;assertEquals('2012-08-22 00:00:00 CEST (offset 7200)',$k-&gt;format('Y-m-d H:i:s T').' (offset '.$k-&gt;getOffset().&quot;)&quot;,'default tz is Amsterdam, date from a string, with timezone, after +0 days');}protected function assertEquals($l,$m,$n=null){if($l!=$m){throw new\Exception(($n?$n.&quot;\n&quot;:&quot;&quot;).&quot;\&quot;$l\&quot; != \&quot;$m\&quot;\n&quot;);}}}$o=new\ReflectionClass(__NAMESPACE__.'\classDateTimeTest');foreach($o-&gt;getMethods()as $p){if(substr($p-&gt;getShortName(),0,4)!=='test')continue;try{$q=new classDateTimeTest();$q-&gt;setup();$p-&gt;invoke($q);$q-&gt;teardown();}catch(\Exception $r){echo 'FAIL: '.$p-&gt;getShortName();$s=$r-&gt;getTrace();echo ' | line '.$s[0]['line'].&quot;\n&quot;;echo $r-&gt;getMessage().&quot;\n&quot;;try{$q-&gt;teardown();}catch(\Exception $r){}continue;}echo 'PASS: '.$p-&gt;getShortName().&quot;\n&quot;;}
Output for 4.3.0 - 5.2.17