3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function date_generator($ex_weeks = array(), $ex_DateTimeObjects = array()) { $kanji_w = array('日', '月', '火', '水', '木', '金', '土'); $now = new DateTime('now', new DateTimezon('Asia/Tokyo')); for ($i = 2; $i < 30; $i++) { $current = $now->add(new DateInterval("P{$i}D")); if (in_array($current->format('w'), $ex_weeks)) { continue; } foreach ($ex_DateTimeObjects as $object) { if (!$object->diff($current)->days) { continue 2; } } $w = $kanji_w[$current->format('w')]; yield $current->format('n月j日') . $w; } } ?> <select name="date"> <?php foreach (date_generator(array(1), array(new DateTime('12/25'))) as $value): ?> <option value="<?=$value?>"><?=$value?></option> <?php endforeach; ?> </select>
Output for 7.0.0 - 7.1.0
<select name="date"> Fatal error: Uncaught Error: Class 'DateTimezon' not found in /in/LDinS:5 Stack trace: #0 /in/LDinS(23): date_generator(Array, Array) #1 {main} thrown in /in/LDinS on line 5
Process exited with code 255.
Output for 5.5.0 - 5.6.25
<select name="date"> Fatal error: Class 'DateTimezon' not found in /in/LDinS on line 5
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '$current' (T_VARIABLE) in /in/LDinS on line 17
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/LDinS on line 17
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_VARIABLE in /in/LDinS on line 17
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/LDinS on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/LDinS on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/LDinS on line 12
Process exited with code 255.