3v4l.org

run code in 300+ PHP versions simultaneously
<?php class day{ public $date; public function __construct() { $this->date = time(); } /** * Should I write code today? * @param (array) $todos Current list of TODOs * @return boolean I should code if true. */ public function doCode($todos) { //return true; //Never stop coding $chore = next($todos); while($chore && $chore->priority < 3 ) $chore = next($todos); return $chore === false || $this->isWeekend($this->date); } /** * Is the date in teh weekend? * @param string $date String date to check * @return boolean True if date is in the weekend */ public function isWeekend($date) { return date('w', $date) % 6 == 0; } } /* End of file day.php */ /* Location: ./life/modules/day/day.php */ $agenda = array( (object)array('priority'=>1) ,(object)array('priority'=>4) ,(object)array('priority'=>1) ,(object)array('priority'=>5) ); $day = new day(); $i = 1; while($i< 10) { echo var_dump(date('w',$day->date)) . "\n"; $day->date = strtotime('+1 day', $day->date); $i++; }
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.6
string(1) "5" string(1) "6" string(1) "0" string(1) "1" string(1) "2" string(1) "3" string(1) "4" string(1) "5" string(1) "6"
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/qFC9b on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/qFC9b on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/qFC9b on line 6
Process exited with code 255.

preferences:
177.84 ms | 401 KiB | 219 Q