3v4l.org

run code in 300+ PHP versions simultaneously
<?php function daysUntil($start, $end) { $days = date('w', strtotime($end)) - date('w', strtotime($start)); $days += $days < 1 ? 7 : 0; return "{$days} days from {$start} to {$end}\n"; } echo daysUntil('Wednesday', 'Saturday'); // Thursday, Friday, Saturday echo daysUntil('Monday', 'Friday'); // Tuesday, Wednesday, Thursday, Friday echo daysUntil('Thursday', 'Thursday'); // [assumed next week] echo daysUntil('Friday', 'Monday'); // Saturday, Sunday, Monday echo daysUntil('Saturday', 'Sunday'); // Sunday echo daysUntil('Sunday', 'Saturday'); // Monday, Tuesday, Wednesday, Thursday, Friday, Saturday echo daysUntil('Sunday', 'Wednesday'); // Monday, Tuesday, Wednesday
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5GsD4
function name:  (null)
number of ops:  36
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'daysuntil'
          1        SEND_VAL                                                 'Wednesday'
          2        SEND_VAL                                                 'Saturday'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
    9     5        INIT_FCALL                                               'daysuntil'
          6        SEND_VAL                                                 'Monday'
          7        SEND_VAL                                                 'Friday'
          8        DO_FCALL                                      0  $1      
          9        ECHO                                                     $1
   10    10        INIT_FCALL                                               'daysuntil'
         11        SEND_VAL                                                 'Thursday'
         12        SEND_VAL                                                 'Thursday'
         13        DO_FCALL                                      0  $2      
         14        ECHO                                                     $2
   11    15        INIT_FCALL                                               'daysuntil'
         16        SEND_VAL                                                 'Friday'
         17        SEND_VAL                                                 'Monday'
         18        DO_FCALL                                      0  $3      
         19        ECHO                                                     $3
   12    20        INIT_FCALL                                               'daysuntil'
         21        SEND_VAL                                                 'Saturday'
         22        SEND_VAL                                                 'Sunday'
         23        DO_FCALL                                      0  $4      
         24        ECHO                                                     $4
   13    25        INIT_FCALL                                               'daysuntil'
         26        SEND_VAL                                                 'Sunday'
         27        SEND_VAL                                                 'Saturday'
         28        DO_FCALL                                      0  $5      
         29        ECHO                                                     $5
   14    30        INIT_FCALL                                               'daysuntil'
         31        SEND_VAL                                                 'Sunday'
         32        SEND_VAL                                                 'Wednesday'
         33        DO_FCALL                                      0  $6      
         34        ECHO                                                     $6
         35      > RETURN                                                   1

Function daysuntil:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5GsD4
function name:  daysUntil
number of ops:  32
compiled vars:  !0 = $start, !1 = $end, !2 = $days
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'date'
          3        SEND_VAL                                                 'w'
          4        INIT_FCALL                                               'strtotime'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                         $4      
          9        INIT_FCALL                                               'date'
         10        SEND_VAL                                                 'w'
         11        INIT_FCALL                                               'strtotime'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $5      
         14        SEND_VAR                                                 $5
         15        DO_ICALL                                         $6      
         16        SUB                                              ~7      $4, $6
         17        ASSIGN                                                   !2, ~7
    4    18        IS_SMALLER                                               !2, 1
         19      > JMPZ                                                     ~9, ->22
         20    >   QM_ASSIGN                                        ~10     7
         21      > JMP                                                      ->23
         22    >   QM_ASSIGN                                        ~10     0
         23    >   ASSIGN_OP                                     1          !2, ~10
    5    24        ROPE_INIT                                     6  ~13     !2
         25        ROPE_ADD                                      1  ~13     ~13, '+days+from+'
         26        ROPE_ADD                                      2  ~13     ~13, !0
         27        ROPE_ADD                                      3  ~13     ~13, '+to+'
         28        ROPE_ADD                                      4  ~13     ~13, !1
         29        ROPE_END                                      5  ~12     ~13, '%0A'
         30      > RETURN                                                   ~12
    6    31*     > RETURN                                                   null

End of function daysuntil

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.5 ms | 1407 KiB | 24 Q