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

End of function yearlydays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.22 ms | 1407 KiB | 20 Q