3v4l.org

run code in 300+ PHP versions simultaneously
<?php $year = 2016; $month = 9; $day = 15; $hour = 11; $min = 32; $sec = 00; $target = mktime($hour, $min, $sec, $month, $day, $year); $current = time(); $difference = $target - $current; print 'current:'.$current.' testDate: '. $target . '\n\r'; function datediffInWeeks($date1, $date2) { if($date1 > $date2) return datediffInWeeks($date2, $date1); $first = DateTime::createFromFormat('U', $date1); $second = DateTime::createFromFormat('U', $date2); return floor($first->diff($second)->days/7); } var_dump(datediffInWeeks($current, $target));// 21 var_dump(datediffInWeeks($current, $target));// 21
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f8abe
function name:  (null)
number of ops:  40
compiled vars:  !0 = $year, !1 = $month, !2 = $day, !3 = $hour, !4 = $min, !5 = $sec, !6 = $target, !7 = $current, !8 = $difference
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 2016
    3     1        ASSIGN                                                   !1, 9
    4     2        ASSIGN                                                   !2, 15
    5     3        ASSIGN                                                   !3, 11
    6     4        ASSIGN                                                   !4, 32
    7     5        ASSIGN                                                   !5, 0
    9     6        INIT_FCALL                                               'mktime'
          7        SEND_VAR                                                 !3
          8        SEND_VAR                                                 !4
          9        SEND_VAR                                                 !5
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $15     
         14        ASSIGN                                                   !6, $15
   10    15        INIT_FCALL                                               'time'
         16        DO_ICALL                                         $17     
         17        ASSIGN                                                   !7, $17
   11    18        SUB                                              ~19     !6, !7
         19        ASSIGN                                                   !8, ~19
   13    20        CONCAT                                           ~21     'current%3A', !7
         21        CONCAT                                           ~22     ~21, '+testDate%3A+'
         22        CONCAT                                           ~23     ~22, !6
         23        CONCAT                                           ~24     ~23, '%5Cn%5Cr'
         24        ECHO                                                     ~24
   25    25        INIT_FCALL                                               'var_dump'
         26        INIT_FCALL                                               'datediffinweeks'
         27        SEND_VAR                                                 !7
         28        SEND_VAR                                                 !6
         29        DO_FCALL                                      0  $25     
         30        SEND_VAR                                                 $25
         31        DO_ICALL                                                 
   26    32        INIT_FCALL                                               'var_dump'
         33        INIT_FCALL                                               'datediffinweeks'
         34        SEND_VAR                                                 !7
         35        SEND_VAR                                                 !6
         36        DO_FCALL                                      0  $27     
         37        SEND_VAR                                                 $27
         38        DO_ICALL                                                 
         39      > 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/f8abe
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
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     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
   20     9    >   INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         10        SEND_VAL                                                 'U'
         11        SEND_VAR                                                 !0
         12        DO_FCALL                                      0  $6      
         13        ASSIGN                                                   !2, $6
   21    14        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         15        SEND_VAL                                                 'U'
         16        SEND_VAR                                                 !1
         17        DO_FCALL                                      0  $8      
         18        ASSIGN                                                   !3, $8
   22    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
   23    28*     > RETURN                                                   null

End of function datediffinweeks

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.16 ms | 1015 KiB | 19 Q