3v4l.org

run code in 300+ PHP versions simultaneously
<?php $query = $_GET['q']; $category = $_GET['catid']; if(check_string($query)) { $query = filter_string($query); } else { echo "Error: Variable is not a string."; die; } function check_string($str) { return preg_match("/^\w+$/", (string)$str); } function filter_string($str) { return preg_replace('/^(.*)$/ie', "filter_function(\"\\1\")", $str); } function filter_function($str) { // do encoding / filtering etc. here return $str; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/OclsK
function name:  (null)
number of ops:  18
compiled vars:  !0 = $query, !1 = $category
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   FETCH_R                      global              ~2      '_GET'
          1        FETCH_DIM_R                                      ~3      ~2, 'q'
          2        ASSIGN                                                   !0, ~3
    3     3        FETCH_R                      global              ~5      '_GET'
          4        FETCH_DIM_R                                      ~6      ~5, 'catid'
          5        ASSIGN                                                   !1, ~6
    4     6        INIT_FCALL_BY_NAME                                       'check_string'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $8      
          9      > JMPZ                                                     $8, ->15
    5    10    >   INIT_FCALL_BY_NAME                                       'filter_string'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !0, $9
         14      > JMP                                                      ->17
    7    15    >   ECHO                                                     'Error%3A+Variable+is+not+a+string.'
    8    16      > EXIT                                                     
   20    17    > > RETURN                                                   1

Function check_string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OclsK
function name:  check_string
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%5E%5Cw%2B%24%2F'
          3        CAST                                          6  ~1      !0
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   12     7*     > RETURN                                                   null

End of function check_string

Function filter_string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OclsK
function name:  filter_string
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%5E%28.%2A%29%24%2Fie'
          3        SEND_VAL                                                 'filter_function%28%22%5C1%22%29'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
   15     7*     > RETURN                                                   null

End of function filter_string

Function filter_function:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OclsK
function name:  filter_function
number of ops:  3
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1      > RETURN                                                   !0
   19     2*     > RETURN                                                   null

End of function filter_function

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.28 ms | 1400 KiB | 17 Q