3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getDay($day) { $days = ['Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6, 'Sunday' => 7]; #$today = new \DateTime(); $today = date("Y-m-d", strtotime("+1 week")); $today->setISODate((int)$today->format('o'), (int)$today->format('W'), $days[ucfirst($day)]); return $today; } var_dump(getDay('Monday')->format('l dS F Y')); var_dump(getDay('Friday')->format('l dS F Y'));
based on Rt2p3
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to a member function setISODate() on string in /in/OsarN:9 Stack trace: #0 /in/OsarN(13): getDay('Monday') #1 {main} thrown in /in/OsarN on line 9
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Fatal error: Call to a member function setISODate() on string in /in/OsarN on line 9
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Fatal error: Call to a member function setISODate() on a non-object in /in/OsarN on line 9
Process exited with code 255.