3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Calculator { /** * Calculate the discount percentage */ function getDiscount($price=0, $sale=0) { $difference = $price-$sale; $discount = ($difference/$price) * 100; if($discount>0) { return $discount; } } } $calculator = new Calculator(); echo $calculator->getDiscount(23,24); if($calculator->getDiscount(23,24)==null){ echo 'No discount'; } echo round(3.6);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/QVdSQ
function name:  (null)
number of ops:  20
compiled vars:  !0 = $calculator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $1      'Calculator'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   18     3        INIT_METHOD_CALL                                         !0, 'getDiscount'
          4        SEND_VAL_EX                                              23
          5        SEND_VAL_EX                                              24
          6        DO_FCALL                                      0  $4      
          7        ECHO                                                     $4
   19     8        INIT_METHOD_CALL                                         !0, 'getDiscount'
          9        SEND_VAL_EX                                              23
         10        SEND_VAL_EX                                              24
         11        DO_FCALL                                      0  $5      
         12        IS_EQUAL                                                 $5, null
         13      > JMPZ                                                     ~6, ->15
         14    >   ECHO                                                     'No+discount'
   22    15    >   INIT_FCALL                                               'round'
         16        SEND_VAL                                                 3.6
         17        DO_ICALL                                         $7      
         18        ECHO                                                     $7
         19      > RETURN                                                   1

Class Calculator:
Function getdiscount:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QVdSQ
function name:  getDiscount
number of ops:  11
compiled vars:  !0 = $price, !1 = $sale, !2 = $difference, !3 = $discount
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      0
          1        RECV_INIT                                        !1      0
    9     2        SUB                                              ~4      !0, !1
          3        ASSIGN                                                   !2, ~4
   10     4        DIV                                              ~6      !2, !0
          5        MUL                                              ~7      ~6, 100
          6        ASSIGN                                                   !3, ~7
   11     7        IS_SMALLER                                               0, !3
          8      > JMPZ                                                     ~9, ->10
   12     9    > > RETURN                                                   !3
   14    10    > > RETURN                                                   null

End of function getdiscount

End of class Calculator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.7 ms | 1388 KiB | 15 Q