3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $_GET['week_of']=20151111; if(!isset($_GET['week_of'][8])&&ctype_digit($_GET['week_of'])&& (DateTime::createFromFormat('Ymd',$_GET['week_of'])->format('N')===1) ){ $week_of=DateTime::createFromFormat('Ymd',$_GET['week_of'])->format('Y-m-d'); }elseif(((new DateTime())->format('N'))==1){ $week_of=new DateTime('this monday'); }else{ $week_of=new DateTime('last monday'); } echo $week_of;
based on MHuMj
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class DateTime could not be converted to string in /in/jK1NU on line 12
Process exited with code 255.
Output for 5.4.9 - 7.0.20
Catchable fatal error: Object of class DateTime could not be converted to string in /in/jK1NU on line 12
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/jK1NU on line 7
Process exited with code 255.