3v4l.org

run code in 300+ PHP versions simultaneously
<?php function yearlyDays($a, $b) { //Takes in two dates and returns the decimal of days per year for that specific year // I made this in order to fix the issue of leap years. if(strtotime($a)<strtotime($b)){ $temp = $a; $a = $b; $b = $a; unset($temp); } $aYearDay = date("z", strtotime($a)) + 1; $aYearDays = date("z", strtotime(date("Y", strtotime($a))."-12-31")) + 1; $aPercent = $aYearDay/$aYearDays; $bYearDay = date("z", strtotime($b)) + 1; $bYearDays = date("z", strtotime(date("Y", strtotime($b))."-12-31")) + 1; $bPercent = $bYearDay/$bYearDays; if(date("Y", strtotime($a))!=date("Y", strtotime($b))) { $aPercent += abs(date("Y", strtotime($a))-date("Y", strtotime($b))); } return $aPercent-$bPercent; } print yearlyDays("2013-05-12", "2012-05-12");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M3pJY
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'yearlydays'
          1        SEND_VAL                                                 '2013-05-12'
          2        SEND_VAL                                                 '2012-05-12'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function yearlydays:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 86, Position 2 = 105
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 105
Branch analysis from position: 14
filename:       /in/M3pJY
function name:  yearlyDays
number of ops:  108
compiled vars:  !0 = $a, !1 = $b, !2 = $temp, !3 = $aYearDay, !4 = $aYearDays, !5 = $aPercent, !6 = $bYearDay, !7 = $bYearDays, !8 = $bPercent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'strtotime'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $9      
          5        INIT_FCALL                                               'strtotime'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $10     
          8        IS_SMALLER                                               $9, $10
          9      > JMPZ                                                     ~11, ->14
    7    10    >   ASSIGN                                                   !2, !0
    8    11        ASSIGN                                                   !0, !1
    9    12        ASSIGN                                                   !1, !0
   10    13        UNSET_CV                                                 !2
   12    14    >   INIT_FCALL                                               'date'
         15        SEND_VAL                                                 'z'
         16        INIT_FCALL                                               'strtotime'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $15     
         19        SEND_VAR                                                 $15
         20        DO_ICALL                                         $16     
         21        ADD                                              ~17     $16, 1
         22        ASSIGN                                                   !3, ~17
   13    23        INIT_FCALL                                               'date'
         24        SEND_VAL                                                 'z'
         25        INIT_FCALL                                               'strtotime'
         26        INIT_FCALL                                               'date'
         27        SEND_VAL                                                 'Y'
         28        INIT_FCALL                                               'strtotime'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $19     
         31        SEND_VAR                                                 $19
         32        DO_ICALL                                         $20     
         33        CONCAT                                           ~21     $20, '-12-31'
         34        SEND_VAL                                                 ~21
         35        DO_ICALL                                         $22     
         36        SEND_VAR                                                 $22
         37        DO_ICALL                                         $23     
         38        ADD                                              ~24     $23, 1
         39        ASSIGN                                                   !4, ~24
   14    40        DIV                                              ~26     !3, !4
         41        ASSIGN                                                   !5, ~26
   15    42        INIT_FCALL                                               'date'
         43        SEND_VAL                                                 'z'
         44        INIT_FCALL                                               'strtotime'
         45        SEND_VAR                                                 !1
         46        DO_ICALL                                         $28     
         47        SEND_VAR                                                 $28
         48        DO_ICALL                                         $29     
         49        ADD                                              ~30     $29, 1
         50        ASSIGN                                                   !6, ~30
   16    51        INIT_FCALL                                               'date'
         52        SEND_VAL                                                 'z'
         53        INIT_FCALL                                               'strtotime'
         54        INIT_FCALL                                               'date'
         55        SEND_VAL                                                 'Y'
         56        INIT_FCALL                                               'strtotime'
         57        SEND_VAR                                                 !1
         58        DO_ICALL                                         $32     
         59        SEND_VAR                                                 $32
         60        DO_ICALL                                         $33     
         61        CONCAT                                           ~34     $33, '-12-31'
         62        SEND_VAL                                                 ~34
         63        DO_ICALL                                         $35     
         64        SEND_VAR                                                 $35
         65        DO_ICALL                                         $36     
         66        ADD                                              ~37     $36, 1
         67        ASSIGN                                                   !7, ~37
   17    68        DIV                                              ~39     !6, !7
         69        ASSIGN                                                   !8, ~39
   18    70        INIT_FCALL                                               'date'
         71        SEND_VAL                                                 'Y'
         72        INIT_FCALL                                               'strtotime'
         73        SEND_VAR                                                 !0
         74        DO_ICALL                                         $41     
         75        SEND_VAR                                                 $41
         76        DO_ICALL                                         $42     
         77        INIT_FCALL                                               'date'
         78        SEND_VAL                                                 'Y'
         79        INIT_FCALL                                               'strtotime'
         80        SEND_VAR                                                 !1
         81        DO_ICALL                                         $43     
         82        SEND_VAR                                                 $43
         83        DO_ICALL                                         $44     
         84        IS_NOT_EQUAL                                             $42, $44
         85      > JMPZ                                                     ~45, ->105
   20    86    >   INIT_FCALL                                               'abs'
         87        INIT_FCALL                                               'date'
         88        SEND_VAL                                                 'Y'
         89        INIT_FCALL                                               'strtotime'
         90        SEND_VAR                                                 !0
         91        DO_ICALL                                         $46     
         92        SEND_VAR                                                 $46
         93        DO_ICALL                                         $47     
         94        INIT_FCALL                                               'date'
         95        SEND_VAL                                                 'Y'
         96        INIT_FCALL                                               'strtotime'
         97        SEND_VAR                                                 !1
         98        DO_ICALL                                         $48     
         99        SEND_VAR                                                 $48
        100        DO_ICALL                                         $49     
        101        SUB                                              ~50     $47, $49
        102        SEND_VAL                                                 ~50
        103        DO_ICALL                                         $51     
        104        ASSIGN_OP                                     1          !5, $51
   22   105    >   SUB                                              ~53     !5, !8
        106      > RETURN                                                   ~53
   23   107*     > RETURN                                                   null

End of function yearlydays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.97 ms | 1407 KiB | 20 Q