3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getNextBinDay() { // First Wednesday bin day of year //$date = strtotime('2020-01-15 00:00:00'); // Current day (numeric) $day = intval( date('N') ); // Get next Wednesday from today $offset = ($day >= 3) ? 10 - $day : 3 - $day; $nextTimestamp = strtotime( '+' . $offset . ' days' ); $dateText = date( 'l jS F', $nextTimestamp ); // Difference in weeks between dates (86400 * 7) //$diff = ceil( ( $nextTimestamp - $date ) / 604800 ); $firstDate = DateTime::createFromFormat( 'Y-m-d H:i:s', '2020-01-15 02:00:00' ); $secondDate = DateTime::createFromFormat( 'Y-m-d H:i:s', date('Y-m-d 02:00:00', $nextTimestamp) ); $diff = $firstDate->diff($secondDate)->days; $bin = ( $diff % 2 === 0 ) ? 'Blue and Brown' : 'Green'; return 'The next bin day in Chorley woooo is ' . $bin . ' bins on ' . $dateText; } var_dump(getNextBinDay());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/toXgt
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'getnextbinday'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
          5      > RETURN                                                   1

Function getnextbinday:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
Branch analysis from position: 48
filename:       /in/toXgt
function name:  getNextBinDay
number of ops:  55
compiled vars:  !0 = $day, !1 = $offset, !2 = $nextTimestamp, !3 = $dateText, !4 = $firstDate, !5 = $secondDate, !6 = $diff, !7 = $bin
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'N'
          2        DO_ICALL                                         $8      
          3        CAST                                          4  ~9      $8
          4        ASSIGN                                                   !0, ~9
   11     5        IS_SMALLER_OR_EQUAL                                      3, !0
          6      > JMPZ                                                     ~11, ->10
          7    >   SUB                                              ~12     10, !0
          8        QM_ASSIGN                                        ~13     ~12
          9      > JMP                                                      ->12
         10    >   SUB                                              ~14     3, !0
         11        QM_ASSIGN                                        ~13     ~14
         12    >   ASSIGN                                                   !1, ~13
   13    13        INIT_FCALL                                               'strtotime'
         14        CONCAT                                           ~16     '%2B', !1
         15        CONCAT                                           ~17     ~16, '+days'
         16        SEND_VAL                                                 ~17
         17        DO_ICALL                                         $18     
         18        ASSIGN                                                   !2, $18
   14    19        INIT_FCALL                                               'date'
         20        SEND_VAL                                                 'l+jS+F'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $20     
         23        ASSIGN                                                   !3, $20
   19    24        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         25        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         26        SEND_VAL                                                 '2020-01-15+02%3A00%3A00'
         27        DO_FCALL                                      0  $22     
         28        ASSIGN                                                   !4, $22
   20    29        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         30        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         31        INIT_FCALL                                               'date'
         32        SEND_VAL                                                 'Y-m-d+02%3A00%3A00'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $24     
         35        SEND_VAR                                                 $24
         36        DO_FCALL                                      0  $25     
         37        ASSIGN                                                   !5, $25
   22    38        INIT_METHOD_CALL                                         !4, 'diff'
         39        SEND_VAR_EX                                              !5
         40        DO_FCALL                                      0  $27     
         41        FETCH_OBJ_R                                      ~28     $27, 'days'
         42        ASSIGN                                                   !6, ~28
   24    43        MOD                                              ~30     !6, 2
         44        IS_IDENTICAL                                             ~30, 0
         45      > JMPZ                                                     ~31, ->48
         46    >   QM_ASSIGN                                        ~32     'Blue+and+Brown'
         47      > JMP                                                      ->49
         48    >   QM_ASSIGN                                        ~32     'Green'
         49    >   ASSIGN                                                   !7, ~32
   26    50        CONCAT                                           ~34     'The+next+bin+day+in+Chorley+woooo+is+', !7
         51        CONCAT                                           ~35     ~34, '+bins+on+'
         52        CONCAT                                           ~36     ~35, !3
         53      > RETURN                                                   ~36
   27    54*     > RETURN                                                   null

End of function getnextbinday

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.72 ms | 1020 KiB | 17 Q