3v4l.org

run code in 300+ PHP versions simultaneously
<?php function format_num($num, $precision = 2) { if ($num >= 1000 && $num < 1000000) { $n_format = number_format($num/1000,$precision).'K'; } else { $n_format = $num; } return $n_format; } echo format_num(1200,1); echo format_num(1230000); echo format_num(1234000000,3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qRCXh
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'format_num'
          1        SEND_VAL                                                 1200
          2        SEND_VAL                                                 1
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   13     5        INIT_FCALL                                               'format_num'
          6        SEND_VAL                                                 1230000
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
   14     9        INIT_FCALL                                               'format_num'
         10        SEND_VAL                                                 1234000000
         11        SEND_VAL                                                 3
         12        DO_FCALL                                      0  $2      
         13        ECHO                                                     $2
         14      > RETURN                                                   1

Function format_num:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/qRCXh
function name:  format_num
number of ops:  18
compiled vars:  !0 = $num, !1 = $precision, !2 = $n_format
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      2
    4     2        IS_SMALLER_OR_EQUAL                              ~3      1000, !0
          3      > JMPZ_EX                                          ~3      ~3, ->6
          4    >   IS_SMALLER                                       ~4      !0, 1000000
          5        BOOL                                             ~3      ~4
          6    > > JMPZ                                                     ~3, ->15
    5     7    >   INIT_FCALL                                               'number_format'
          8        DIV                                              ~5      !0, 1000
          9        SEND_VAL                                                 ~5
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $6      
         12        CONCAT                                           ~7      $6, 'K'
         13        ASSIGN                                                   !2, ~7
         14      > JMP                                                      ->16
    7    15    >   ASSIGN                                                   !2, !0
    9    16    > > RETURN                                                   !2
   10    17*     > RETURN                                                   null

End of function format_num

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.21 ms | 1399 KiB | 18 Q