3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calc_string($string) { $calc = create_function("", "return (" . preg_replace('[^0-9\+-\*\/\(\) ]', '', trim($string)) . ");" ); return $calc(); } echo calc_string("6 * ((26 / 2) + -3) - 20");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mluF9
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'calc_string'
          1        SEND_VAL                                                 '6+%2A+%28%2826+%2F+2%29+%2B+-3%29+-+20'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function calc_string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mluF9
function name:  calc_string
number of ops:  20
compiled vars:  !0 = $string, !1 = $calc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL_BY_NAME                                       'create_function'
          2        SEND_VAL_EX                                              ''
          3        INIT_FCALL                                               'preg_replace'
          4        SEND_VAL                                                 '%5B%5E0-9%5C%2B-%5C%2A%5C%2F%5C%28%5C%29+%5D'
          5        SEND_VAL                                                 ''
          6        INIT_FCALL                                               'trim'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $2      
          9        SEND_VAR                                                 $2
         10        DO_ICALL                                         $3      
         11        CONCAT                                           ~4      'return+%28', $3
         12        CONCAT                                           ~5      ~4, '%29%3B'
         13        SEND_VAL_EX                                              ~5
         14        DO_FCALL                                      0  $6      
         15        ASSIGN                                                   !1, $6
    5    16        INIT_DYNAMIC_CALL                                        !1
         17        DO_FCALL                                      0  $8      
         18      > RETURN                                                   $8
    6    19*     > RETURN                                                   null

End of function calc_string

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.43 ms | 1397 KiB | 21 Q