3v4l.org

run code in 200+ 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_generateor(array(1), array(new DateTime('12/25'))) as $value): ?> <option value="<?=$value?>"><?=$value?></option> <?php endforeach; ?> </select>
Output for 7.0.0 - 7.3.0rc4
<select name="date"> Fatal error: Uncaught Error: Call to undefined function date_generateor() in /in/Q526F:23 Stack trace: #0 {main} thrown in /in/Q526F on line 23
Process exited with code 255.
Output for 5.5.0 - 5.6.28
<select name="date"> Fatal error: Call to undefined function date_generateor() in /in/Q526F on line 23
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '$current' (T_VARIABLE) in /in/Q526F on line 17
Process exited with code 255.
Output for 5.2.3 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/Q526F on line 17
Process exited with code 255.
Output for 5.1.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected T_VARIABLE in <b>/in/Q526F</b> on line <b>17</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected T_VARIABLE in <b>/in/Q526F</b> on line <b>17</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_OBJECT_OPERATOR in <b>/in/Q526F</b> on line <b>12</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_OBJECT_OPERATOR in <b>/in/Q526F</b> on line <b>12</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/Q526F</b> on line <b>12</b><br />
Process exited with code 255.