3v4l.org

run code in 500+ PHP versions simultaneously
<?php function toCents($amount) { $cents = explode(',', $amount); if (!isset($cents[1])) $cents[1] = '00'; return (int) implode($cents); } $amount = '10,95'; echo toCents($amount); echo ' - '; $amount = '150'; echo toCents($amount);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/97Zfr
function name:  (null)
number of ops:  12
compiled vars:  !0 = $amount
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                       !0, '10%2C95'
   10     1        INIT_FCALL                                                   'tocents'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $2      
          4        ECHO                                                         $2
   12     5        ECHO                                                         '+-+'
   14     6        ASSIGN                                                       !0, '150'
   15     7        INIT_FCALL                                                   'tocents'
          8        SEND_VAR                                                     !0
          9        DO_FCALL                                          0  $4      
         10        ECHO                                                         $4
         11      > RETURN                                                       1

Function tocents:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/97Zfr
function name:  toCents
number of ops:  15
compiled vars:  !0 = $amount, !1 = $cents
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '%2C'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $2      
          5        ASSIGN                                                       !1, $2
    5     6        ISSET_ISEMPTY_DIM_OBJ                             0  ~4      !1, 1
          7        BOOL_NOT                                             ~5      ~4
          8      > JMPZ                                                         ~5, ->11
          9    >   ASSIGN_DIM                                                   !1, 1
         10        OP_DATA                                                      '00'
    6    11    >   FRAMELESS_ICALL_1                implode             ~7      !1
         12        CAST                                              4  ~8      ~7
         13      > RETURN                                                       ~8
    7    14*     > RETURN                                                       null

End of function tocents

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
149.28 ms | 3279 KiB | 16 Q