3v4l.org

run code in 500+ PHP versions simultaneously
<?php function calculate_due($num_installment, $first_due_date = null, $days = 1){ $start = DateTime::createFromFormat('d/m/Y', $first_due_date); $end = DateTime::createFromFormat('d/m/Y', $first_due_date); $end->add(new DateInterval('P'.($num_installment * $days).'D')); $period = new DatePeriod( $start, new DateInterval('P'.$days.'D'), $end ); $return = []; foreach ($period as $date) { $return[] = $date->format('d/m/Y'); } return $return; } echo 'Calculates installments from an informed date<br/>'.PHP_EOL;; echo implode("\n", calculate_due(5, '10/10/2020', 20));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TLR8a
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   ECHO                                                         'Calculates+installments+from+an+informed+date%3Cbr%2F%3E%0A'
   24     1        INIT_FCALL                                                   'calculate_due'
          2        SEND_VAL                                                     5
          3        SEND_VAL                                                     '10%2F10%2F2020'
          4        SEND_VAL                                                     20
          5        DO_FCALL                                          0  $0      
          6        FRAMELESS_ICALL_2                implode             ~1      '%0A', $0
          7        ECHO                                                         ~1
          8      > RETURN                                                       1

Function calculate_due:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 35, Position 2 = 42
Branch analysis from position: 35
2 jumps found. (Code = 78) Position 1 = 36, Position 2 = 42
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/TLR8a
function name:  calculate_due
number of ops:  45
compiled vars:  !0 = $num_installment, !1 = $first_due_date, !2 = $days, !3 = $start, !4 = $end, !5 = $period, !6 = $return, !7 = $date
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      null
          2        RECV_INIT                                            !2      1
    4     3        INIT_STATIC_METHOD_CALL                                      'DateTime', 'createFromFormat'
          4        SEND_VAL                                                     'd%2Fm%2FY'
          5        SEND_VAR                                                     !1
          6        DO_FCALL                                          0  $8      
          7        ASSIGN                                                       !3, $8
    6     8        INIT_STATIC_METHOD_CALL                                      'DateTime', 'createFromFormat'
          9        SEND_VAL                                                     'd%2Fm%2FY'
         10        SEND_VAR                                                     !1
         11        DO_FCALL                                          0  $10     
         12        ASSIGN                                                       !4, $10
    7    13        INIT_METHOD_CALL                                             !4, 'add'
         14        NEW                                                  $12     'DateInterval'
         15        MUL                                                  ~13     !0, !2
         16        CONCAT                                               ~14     'P', ~13
         17        CONCAT                                               ~15     ~14, 'D'
         18        SEND_VAL_EX                                                  ~15
         19        DO_FCALL                                          0          
         20        SEND_VAR_NO_REF_EX                                           $12
         21        DO_FCALL                                          0          
    9    22        NEW                                                  $18     'DatePeriod'
   10    23        SEND_VAR_EX                                                  !3
   11    24        NEW                                                  $19     'DateInterval'
         25        CONCAT                                               ~20     'P', !2
         26        CONCAT                                               ~21     ~20, 'D'
         27        SEND_VAL_EX                                                  ~21
         28        DO_FCALL                                          0          
         29        SEND_VAR_NO_REF_EX                                           $19
   10    30        SEND_VAR_EX                                                  !4
    9    31        DO_FCALL                                          0          
         32        ASSIGN                                                       !5, $18
   15    33        ASSIGN                                                       !6, <array>
   16    34      > FE_RESET_R                                           $26     !5, ->42
         35    > > FE_FETCH_R                                                   $26, !7, ->42
   17    36    >   INIT_METHOD_CALL                                             !7, 'format'
         37        SEND_VAL_EX                                                  'd%2Fm%2FY'
         38        DO_FCALL                                          0  $28     
         39        ASSIGN_DIM                                                   !6
         40        OP_DATA                                                      $28
   16    41      > JMP                                                          ->35
         42    >   FE_FREE                                                      $26
   19    43      > RETURN                                                       !6
   20    44*     > RETURN                                                       null

End of function calculate_due

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
128.9 ms | 483 KiB | 8 Q