3v4l.org

run code in 300+ PHP versions simultaneously
<?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.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<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.5.35, 5.6.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.2.17, 5.3.0 - 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.1.6, 5.2.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.3.11, 4.4.0 - 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.

preferences:
264.86 ms | 401 KiB | 346 Q