3v4l.org

run code in 300+ PHP versions simultaneously
<?php function datediffInWeeks($date1, $date2) { if($date1 > $date2) return datediffInWeeks($date2, $date1); $first = DateTime::createFromFormat('m/d/Y', $date1); $second = DateTime::createFromFormat('m/d/Y', $date2); return floor($first->diff($second)->days/7); } var_dump(datediffInWeeks('1/2/2013', '6/4/2013'));// 21 var_dump(datediffInWeeks('6/4/2013', '1/2/2013'));// 21
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2INlc
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'datediffinweeks'
          2        SEND_VAL                                                 '1%2F2%2F2013'
          3        SEND_VAL                                                 '6%2F4%2F2013'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   11     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'datediffinweeks'
          9        SEND_VAL                                                 '6%2F4%2F2013'
         10        SEND_VAL                                                 '1%2F2%2F2013'
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function datediffinweeks:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2INlc
function name:  datediffInWeeks
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        IS_SMALLER                                               !1, !0
          3      > JMPZ                                                     ~4, ->9
          4    >   INIT_FCALL_BY_NAME                                       'datediffInWeeks'
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $5      
          8      > RETURN                                                   $5
    5     9    >   INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         10        SEND_VAL                                                 'm%2Fd%2FY'
         11        SEND_VAR                                                 !0
         12        DO_FCALL                                      0  $6      
         13        ASSIGN                                                   !2, $6
    6    14        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         15        SEND_VAL                                                 'm%2Fd%2FY'
         16        SEND_VAR                                                 !1
         17        DO_FCALL                                      0  $8      
         18        ASSIGN                                                   !3, $8
    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 datediffinweeks

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.63 ms | 1009 KiB | 17 Q