3v4l.org

run code in 300+ PHP versions simultaneously
<?php //-------------------------------------------------- // Just while the function is re-named if (!function_exists('is_trusted')) { function is_trusted($value) { return is_literal($value); } } //-------------------------------------------------- $limit = trim(' 100 '); // Not trusted $_GET['ids'] = [trim(' 1 '), 2, 3]; var_dump($_GET['ids'][0], is_trusted($_GET['ids'][0])); $ids_untrusted = ( $_GET['ids'] ?? [] ); $ids_trusted = array_map( 'intval', $ids_untrusted ); //-------------------------------------------------- $sql = 'SELECT * FROM foo WHERE id IN (' . implode( ',', $ids_untrusted ) . ')'; // Whoops var_dump($sql, is_trusted($sql)); //-------------------------------------------------- $sql = 'SELECT * FROM foo WHERE id IN (' . implode( ',', $ids_trusted ) . ')'; var_dump($sql, is_trusted($sql)); //-------------------------------------------------- $sql = sprintf( 'SELECT * FROM foo WHERE id IN (%s)', implode( ',', $ids_trusted ) ); var_dump($sql, is_trusted($sql)); //-------------------------------------------------- $sql = sprintf( 'SELECT * FROM foo LIMIT %d', (int)$limit ); var_dump($sql, is_trusted($sql)); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/FvtpW
function name:  (null)
number of ops:  101
compiled vars:  !0 = $limit, !1 = $ids_untrusted, !2 = $ids_trusted, !3 = $sql
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'is_trusted'
          2        DO_ICALL                                         $4      
          3        BOOL_NOT                                         ~5      $4
          4      > JMPZ                                                     ~5, ->6
    7     5    >   DECLARE_FUNCTION                                         'is_trusted'
   14     6    >   INIT_FCALL                                               'trim'
          7        SEND_VAL                                                 '+100+'
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !0, $6
   16    10        INIT_FCALL                                               'trim'
         11        SEND_VAL                                                 '+1+'
         12        DO_ICALL                                         $10     
         13        INIT_ARRAY                                       ~11     $10
         14        ADD_ARRAY_ELEMENT                                ~11     2
         15        ADD_ARRAY_ELEMENT                                ~11     3
         16        FETCH_W                      global              $8      '_GET'
         17        ASSIGN_DIM                                               $8, 'ids'
         18        OP_DATA                                                  ~11
   18    19        INIT_FCALL                                               'var_dump'
         20        FETCH_R                      global              ~12     '_GET'
         21        FETCH_DIM_R                                      ~13     ~12, 'ids'
         22        FETCH_DIM_R                                      ~14     ~13, 0
         23        SEND_VAL                                                 ~14
         24        INIT_FCALL_BY_NAME                                       'is_trusted'
         25        CHECK_FUNC_ARG                                           
         26        FETCH_FUNC_ARG               global              $15     '_GET'
         27        FETCH_DIM_FUNC_ARG                               $16     $15, 'ids'
         28        FETCH_DIM_FUNC_ARG                               $17     $16, 0
         29        SEND_FUNC_ARG                                            $17
         30        DO_FCALL                                      0  $18     
         31        SEND_VAR                                                 $18
         32        DO_ICALL                                                 
   20    33        FETCH_IS                                         ~20     '_GET'
         34        FETCH_DIM_IS                                     ~21     ~20, 'ids'
         35        COALESCE                                         ~22     ~21
         36        QM_ASSIGN                                        ~22     <array>
         37        ASSIGN                                                   !1, ~22
   21    38        INIT_FCALL                                               'array_map'
         39        SEND_VAL                                                 'intval'
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                         $24     
         42        ASSIGN                                                   !2, $24
   25    43        INIT_FCALL                                               'implode'
         44        SEND_VAL                                                 '%2C'
         45        SEND_VAR                                                 !1
         46        DO_ICALL                                         $26     
         47        CONCAT                                           ~27     'SELECT+%2A+FROM+foo+WHERE+id+IN+%28', $26
         48        CONCAT                                           ~28     ~27, '%29'
         49        ASSIGN                                                   !3, ~28
   27    50        INIT_FCALL                                               'var_dump'
         51        SEND_VAR                                                 !3
         52        INIT_FCALL_BY_NAME                                       'is_trusted'
         53        SEND_VAR_EX                                              !3
         54        DO_FCALL                                      0  $30     
         55        SEND_VAR                                                 $30
         56        DO_ICALL                                                 
   31    57        INIT_FCALL                                               'implode'
         58        SEND_VAL                                                 '%2C'
         59        SEND_VAR                                                 !2
         60        DO_ICALL                                         $32     
         61        CONCAT                                           ~33     'SELECT+%2A+FROM+foo+WHERE+id+IN+%28', $32
         62        CONCAT                                           ~34     ~33, '%29'
         63        ASSIGN                                                   !3, ~34
   33    64        INIT_FCALL                                               'var_dump'
         65        SEND_VAR                                                 !3
         66        INIT_FCALL_BY_NAME                                       'is_trusted'
         67        SEND_VAR_EX                                              !3
         68        DO_FCALL                                      0  $36     
         69        SEND_VAR                                                 $36
         70        DO_ICALL                                                 
   37    71        INIT_FCALL                                               'sprintf'
         72        SEND_VAL                                                 'SELECT+%2A+FROM+foo+WHERE+id+IN+%28%25s%29'
         73        INIT_FCALL                                               'implode'
         74        SEND_VAL                                                 '%2C'
         75        SEND_VAR                                                 !2
         76        DO_ICALL                                         $38     
         77        SEND_VAR                                                 $38
         78        DO_ICALL                                         $39     
         79        ASSIGN                                                   !3, $39
   39    80        INIT_FCALL                                               'var_dump'
         81        SEND_VAR                                                 !3
         82        INIT_FCALL_BY_NAME                                       'is_trusted'
         83        SEND_VAR_EX                                              !3
         84        DO_FCALL                                      0  $41     
         85        SEND_VAR                                                 $41
         86        DO_ICALL                                                 
   43    87        INIT_FCALL                                               'sprintf'
         88        SEND_VAL                                                 'SELECT+%2A+FROM+foo+LIMIT+%25d'
         89        CAST                                          4  ~43     !0
         90        SEND_VAL                                                 ~43
         91        DO_ICALL                                         $44     
         92        ASSIGN                                                   !3, $44
   45    93        INIT_FCALL                                               'var_dump'
         94        SEND_VAR                                                 !3
         95        INIT_FCALL_BY_NAME                                       'is_trusted'
         96        SEND_VAR_EX                                              !3
         97        DO_FCALL                                      0  $46     
         98        SEND_VAR                                                 $46
         99        DO_ICALL                                                 
   47   100      > RETURN                                                   1

Function %00is_trusted%2Fin%2FFvtpW%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FvtpW
function name:  is_trusted
number of ops:  6
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL_BY_NAME                                       'is_literal'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
    9     5*     > RETURN                                                   null

End of function %00is_trusted%2Fin%2FFvtpW%3A7%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.93 ms | 1408 KiB | 26 Q