3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getSql($arr) { $sql = 'SELECT id FROM table1 WHERE '; $and = ''; foreach ($arr as $a) { $sql .= $and . "'$a' IN (cat1, cat2, cat3) "; $and = ' AND '; } return $sql; } echo getSql(array('a')); // one choice echo "\n"; echo getSql(array('a', 'b')); // two choices echo '<br>'; echo getSql(array('a', 'b', 'c')); // three choices ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/39vjH
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'getsql'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   16     4        ECHO                                                     '%0A'
   17     5        INIT_FCALL                                               'getsql'
          6        SEND_VAL                                                 <array>
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
   18     9        ECHO                                                     '%3Cbr%3E'
   19    10        INIT_FCALL                                               'getsql'
         11        SEND_VAL                                                 <array>
         12        DO_FCALL                                      0  $2      
         13        ECHO                                                     $2
   21    14      > RETURN                                                   1

Function getsql:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/39vjH
function name:  getSql
number of ops:  15
compiled vars:  !0 = $arr, !1 = $sql, !2 = $and, !3 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, 'SELECT+id+FROM+table1+WHERE+'
    5     2        ASSIGN                                                   !2, ''
    7     3      > FE_RESET_R                                       $6      !0, ->12
          4    > > FE_FETCH_R                                               $6, !3, ->12
    8     5    >   ROPE_INIT                                     3  ~8      '%27'
          6        ROPE_ADD                                      1  ~8      ~8, !3
          7        ROPE_END                                      2  ~7      ~8, '%27+IN+%28cat1%2C+cat2%2C+cat3%29+'
          8        CONCAT                                           ~10     !2, ~7
          9        ASSIGN_OP                                     8          !1, ~10
    9    10        ASSIGN                                                   !2, '+AND+'
    7    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $6
   12    13      > RETURN                                                   !1
   13    14*     > RETURN                                                   null

End of function getsql

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.74 ms | 1399 KiB | 16 Q