3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_GET['user_id'] = 3; $query[] = "select * from preferences user_id = "; $query[] = $_GET['user_id']; db_exec($query); function db_exec(string|array $query_parts) { if (is_string($query_parts) && !is_literal($query_parts)) { throw new \Exception("Cannot use non literal string as query. Please pass the parts in as an array"); } else { foreach ($query_parts as $query_part) { if (is_string($query_part) && !is_literal($query_part)) { throw new \Exception("non-literal string found [$query_part]"); } else if (is_int($query_part)) { // todo - decide if you want to allow this or not. // I personally wouldn't. } else { // todo - support other types } } var_dump(implode("", $query_parts)); } // rest of db_exec here... }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aCFIT
function name:  (null)
number of ops:  13
compiled vars:  !0 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_W                      global              $1      '_GET'
          1        ASSIGN_DIM                                               $1, 'user_id'
          2        OP_DATA                                                  3
    5     3        ASSIGN_DIM                                               !0
          4        OP_DATA                                                  'select+%2A+from+preferences+user_id+%3D+'
    6     5        FETCH_R                      global              ~5      '_GET'
          6        FETCH_DIM_R                                      ~6      ~5, 'user_id'
          7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  ~6
    8     9        INIT_FCALL_BY_NAME                                       'db_exec'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   33    12      > RETURN                                                   1

Function db_exec:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 36
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 36
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 32
Branch analysis from position: 24
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 35
Branch analysis from position: 23
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 8
filename:       /in/aCFIT
function name:  db_exec
number of ops:  45
compiled vars:  !0 = $query_parts, !1 = $query_part
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        TYPE_CHECK                                   64  ~2      !0
          2      > JMPZ_EX                                          ~2      ~2, ->8
          3    >   INIT_FCALL_BY_NAME                                       'is_literal'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $3      
          6        BOOL_NOT                                         ~4      $3
          7        BOOL                                             ~2      ~4
          8    > > JMPZ                                                     ~2, ->14
   13     9    >   NEW                                              $5      'Exception'
         10        SEND_VAL_EX                                              'Cannot+use+non+literal+string+as+query.%0APlease+pass+the+parts+in+as+an+array'
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $5
         13*       JMP                                                      ->44
   16    14    > > FE_RESET_R                                       $7      !0, ->36
         15    > > FE_FETCH_R                                               $7, !1, ->36
   17    16    >   TYPE_CHECK                                   64  ~8      !1
         17      > JMPZ_EX                                          ~8      ~8, ->23
         18    >   INIT_FCALL_BY_NAME                                       'is_literal'
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0  $9      
         21        BOOL_NOT                                         ~10     $9
         22        BOOL                                             ~8      ~10
         23    > > JMPZ                                                     ~8, ->32
   18    24    >   NEW                                              $11     'Exception'
         25        ROPE_INIT                                     3  ~13     'non-literal+string+found+%5B'
         26        ROPE_ADD                                      1  ~13     ~13, !1
         27        ROPE_END                                      2  ~12     ~13, '%5D'
         28        SEND_VAL_EX                                              ~12
         29        DO_FCALL                                      0          
         30      > THROW                                         0          $11
         31*       JMP                                                      ->35
   20    32    >   TYPE_CHECK                                   16          !1
         33      > JMPZ                                                     ~16, ->35
         34    > > JMP                                                      ->35
   16    35    > > JMP                                                      ->15
         36    >   FE_FREE                                                  $7
   29    37        INIT_FCALL                                               'var_dump'
         38        INIT_FCALL                                               'implode'
         39        SEND_VAL                                                 ''
         40        SEND_VAR                                                 !0
         41        DO_ICALL                                         $17     
         42        SEND_VAR                                                 $17
         43        DO_ICALL                                                 
   33    44      > RETURN                                                   null

End of function db_exec

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.84 ms | 1400 KiB | 17 Q