3v4l.org

run code in 300+ PHP versions simultaneously
<?php function week_between_two_dates($date1, $date2) { $first = DateTime::createFromFormat('m/d/Y', $date1); $second = DateTime::createFromFormat('m/d/Y', $date2); if($date1 > $date2) return week_between_two_dates($date2, $date1); return floor($first->diff($second)->days/7); } $dt1 = '1/1/2014'; $dt2 = '12/31/2014'; echo 'Weeks between '.$dt1.' and '. $dt2. ' is '. week_between_two_dates($dt1, $dt2)."\n"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gLGJO
function name:  (null)
number of ops:  14
compiled vars:  !0 = $dt1, !1 = $dt2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, '1%2F1%2F2014'
   11     1        ASSIGN                                                   !1, '12%2F31%2F2014'
   12     2        CONCAT                                           ~4      'Weeks+between+', !0
          3        CONCAT                                           ~5      ~4, '+and+'
          4        CONCAT                                           ~6      ~5, !1
          5        CONCAT                                           ~7      ~6, '+is+'
          6        INIT_FCALL                                               'week_between_two_dates'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $8      
         10        CONCAT                                           ~9      ~7, $8
         11        CONCAT                                           ~10     ~9, '%0A'
         12        ECHO                                                     ~10
   13    13      > RETURN                                                   1

Function week_between_two_dates:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gLGJO
function name:  week_between_two_dates
number of ops:  29
compiled vars:  !0 = $date1, !1 = $date2, !2 = $first, !3 = $second
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          3        SEND_VAL                                                 'm%2Fd%2FY'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !2, $4
    5     7        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          8        SEND_VAL                                                 'm%2Fd%2FY'
          9        SEND_VAR                                                 !1
         10        DO_FCALL                                      0  $6      
         11        ASSIGN                                                   !3, $6
    6    12        IS_SMALLER                                               !1, !0
         13      > JMPZ                                                     ~8, ->19
         14    >   INIT_FCALL_BY_NAME                                       'week_between_two_dates'
         15        SEND_VAR_EX                                              !1
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0  $9      
         18      > RETURN                                                   $9
    7    19    >   INIT_FCALL                                               'floor'
         20        INIT_METHOD_CALL                                         !2, 'diff'
         21        SEND_VAR_EX                                              !3
         22        DO_FCALL                                      0  $10     
         23        FETCH_OBJ_R                                      ~11     $10, 'days'
         24        DIV                                              ~12     ~11, 7
         25        SEND_VAL                                                 ~12
         26        DO_ICALL                                         $13     
         27      > RETURN                                                   $13
    8    28*     > RETURN                                                   null

End of function week_between_two_dates

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.74 ms | 1403 KiB | 16 Q