3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _AVG($args){ /*$count = func_num_args(); $args = func_get_args();*/ $count = count($args); $sum = array_sum($args); return bcdiv($sum,$count,2); } function _AVG1($args){ /*$count = func_num_args(); $args = func_get_args();*/ $count = count($args); //$sum = array_sum($args); return array_sum($args) / $count; } $avg = _AVG(array(3.17,2.22,2.54)); $addmtg = bcadd($avg,3.17,2); $mul95 = bcmul($addmtg,0.95,2); $div2 = bcdiv($mul95,2,2); echo $div2;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BHvBr
function name:  (null)
number of ops:  24
compiled vars:  !0 = $avg, !1 = $addmtg, !2 = $mul95, !3 = $div2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               '_avg'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $4      
          3        ASSIGN                                                   !0, $4
   17     4        INIT_FCALL_BY_NAME                                       'bcadd'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              3.17
          7        SEND_VAL_EX                                              2
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !1, $6
   18    10        INIT_FCALL_BY_NAME                                       'bcmul'
         11        SEND_VAR_EX                                              !1
         12        SEND_VAL_EX                                              0.95
         13        SEND_VAL_EX                                              2
         14        DO_FCALL                                      0  $8      
         15        ASSIGN                                                   !2, $8
   19    16        INIT_FCALL_BY_NAME                                       'bcdiv'
         17        SEND_VAR_EX                                              !2
         18        SEND_VAL_EX                                              2
         19        SEND_VAL_EX                                              2
         20        DO_FCALL                                      0  $10     
         21        ASSIGN                                                   !3, $10
   20    22        ECHO                                                     !3
         23      > RETURN                                                   1

Function _avg:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BHvBr
function name:  _AVG
number of ops:  14
compiled vars:  !0 = $args, !1 = $count, !2 = $sum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    5     1        COUNT                                            ~3      !0
          2        ASSIGN                                                   !1, ~3
    6     3        INIT_FCALL                                               'array_sum'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
    7     7        INIT_FCALL_BY_NAME                                       'bcdiv'
          8        SEND_VAR_EX                                              !2
          9        SEND_VAR_EX                                              !1
         10        SEND_VAL_EX                                              2
         11        DO_FCALL                                      0  $7      
         12      > RETURN                                                   $7
    8    13*     > RETURN                                                   null

End of function _avg

Function _avg1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BHvBr
function name:  _AVG1
number of ops:  9
compiled vars:  !0 = $args, !1 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   12     1        COUNT                                            ~2      !0
          2        ASSIGN                                                   !1, ~2
   14     3        INIT_FCALL                                               'array_sum'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        DIV                                              ~5      $4, !1
          7      > RETURN                                                   ~5
   15     8*     > RETURN                                                   null

End of function _avg1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.45 ms | 1406 KiB | 17 Q