3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [5, "David"]; $query = "SELECT * FROM users WHERE user_id = ? AND user_name = ?"; function logger($query, $arr) { foreach($arr as $a) { $query = is_numeric($a) ? preg_replace("/(?<=\s)\?(?=\s|$)/", $a, $query, 1) : preg_replace("/(?<=\s)\?(?=\s|$)/", "'$a'", $query, 1); } return $query; } echo logger($query, $arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nL5oI
function name:  (null)
number of ops:  8
compiled vars:  !0 = $arr, !1 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 'SELECT+%2A+FROM+users+WHERE+user_id+%3D+%3F+AND+user_name+%3D+%3F'
   15     2        INIT_FCALL                                               'logger'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
          7      > RETURN                                                   1

Function logger:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 28
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/nL5oI
function name:  logger
number of ops:  31
compiled vars:  !0 = $query, !1 = $arr, !2 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2      > FE_RESET_R                                       $3      !1, ->28
          3    > > FE_FETCH_R                                               $3, !2, ->28
    8     4    >   INIT_FCALL                                               'is_numeric'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $4      
          7      > JMPZ                                                     $4, ->16
    9     8    >   INIT_FCALL                                               'preg_replace'
          9        SEND_VAL                                                 '%2F%28%3F%3C%3D%5Cs%29%5C%3F%28%3F%3D%5Cs%7C%24%29%2F'
         10        SEND_VAR                                                 !2
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 1
         13        DO_ICALL                                         $5      
         14        QM_ASSIGN                                        ~6      $5
         15      > JMP                                                      ->26
   10    16    >   INIT_FCALL                                               'preg_replace'
         17        SEND_VAL                                                 '%2F%28%3F%3C%3D%5Cs%29%5C%3F%28%3F%3D%5Cs%7C%24%29%2F'
         18        ROPE_INIT                                     3  ~8      '%27'
         19        ROPE_ADD                                      1  ~8      ~8, !2
         20        ROPE_END                                      2  ~7      ~8, '%27'
         21        SEND_VAL                                                 ~7
         22        SEND_VAR                                                 !0
         23        SEND_VAL                                                 1
         24        DO_ICALL                                         $10     
         25        QM_ASSIGN                                        ~6      $10
    8    26    >   ASSIGN                                                   !0, ~6
    7    27      > JMP                                                      ->3
         28    >   FE_FREE                                                  $3
   12    29      > RETURN                                                   !0
   13    30*     > RETURN                                                   null

End of function logger

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.55 ms | 1008 KiB | 16 Q