3v4l.org

run code in 300+ PHP versions simultaneously
<?php // -- PULLING IN PRODUCTS TO READ OUT TO USER -- // $stmt = (" SELECT products.ID, products.title, products.category, products.location, products.price, products.negotiable, products.description, products.photo, products.user_id FROM products"); $result = $db->query($stmt); foreach ($result as $row) { $product_id = $row['ID']; $title = htmlspecialchars($row['title'], ENT_QUOTES); // User input, prevent first order XSS $category = $row['category']; // local variable for remainder, ensuring to use htmlspecialchars() for any user input that will be read out to browser } // -- INSERTING ONE PRODUCT TO MAIN PRODUCT PAGE USING PREPARED STATEMENT -- // // Incoming user input from some form // Assign input to local variables // Probably should validate data $null_value = null; // To bind null values... I'm lazy $stmt = $db->prepare(" INSERT INTO products VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->bind_param('sssssssss', $null_value, $title, $category, $location, $price, $negotiable, $description, $photo, $user_id); $stmt->execute(); // -- INSERTING MULTIPLE PRODUCTS TO MAIN PRODUCT PAGE USING PREPARED STATEMENT -- // // Incoming user input from some form $null_value = null; // To bind null values... I'm lazy // Assuming user input is from a form // Verify it is a form submission if($_SERVER['REQUEST_METHOD'] === 'POST') { foreach ($_POST['product_array'] as $product) { foreach ($product as $row) { // Validate data types // Assign to to local variables $stmt = $db->prepare(" INSERT INTO products VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->bind_param('sssssssss', $null_value, $title, $category, $location, $price, $negotiable, $description, $photo, $user_id); $stmt->execute(); } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 71
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 46, Position 2 = 70
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 70
Branch analysis from position: 47
2 jumps found. (Code = 77) Position 1 = 48, Position 2 = 68
Branch analysis from position: 48
2 jumps found. (Code = 78) Position 1 = 49, Position 2 = 68
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 68
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
Branch analysis from position: 71
Branch analysis from position: 18
filename:       /in/Obdml
function name:  (null)
number of ops:  72
compiled vars:  !0 = $stmt, !1 = $result, !2 = $db, !3 = $row, !4 = $product_id, !5 = $title, !6 = $category, !7 = $null_value, !8 = $location, !9 = $price, !10 = $negotiable, !11 = $description, !12 = $photo, !13 = $user_id, !14 = $product
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, '%0A++++SELECT%0A++++++++products.ID%2C%0A++++++++products.title%2C%0A++++++++products.category%2C%0A++++++++products.location%2C%0A++++++++products.price%2C%0A++++++++products.negotiable%2C%0A++++++++products.description%2C%0A++++++++products.photo%2C%0A++++++++products.user_id%0A++++FROM%0A++++++++products'
   20     1        INIT_METHOD_CALL                                         !2, 'query'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $16     
          4        ASSIGN                                                   !1, $16
   22     5      > FE_RESET_R                                       $18     !1, ->18
          6    > > FE_FETCH_R                                               $18, !3, ->18
   23     7    >   FETCH_DIM_R                                      ~19     !3, 'ID'
          8        ASSIGN                                                   !4, ~19
   24     9        INIT_FCALL                                               'htmlspecialchars'
         10        FETCH_DIM_R                                      ~21     !3, 'title'
         11        SEND_VAL                                                 ~21
         12        SEND_VAL                                                 3
         13        DO_ICALL                                         $22     
         14        ASSIGN                                                   !5, $22
   25    15        FETCH_DIM_R                                      ~24     !3, 'category'
         16        ASSIGN                                                   !6, ~24
   22    17      > JMP                                                      ->6
         18    >   FE_FREE                                                  $18
   36    19        ASSIGN                                                   !7, null
   38    20        INIT_METHOD_CALL                                         !2, 'prepare'
         21        SEND_VAL_EX                                              '%0A++++INSERT+INTO%0A++++++++products%0A++++VALUES%0A++++++++%28%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%29'
         22        DO_FCALL                                      0  $27     
         23        ASSIGN                                                   !0, $27
   44    24        INIT_METHOD_CALL                                         !0, 'bind_param'
         25        SEND_VAL_EX                                              'sssssssss'
         26        SEND_VAR_EX                                              !7
         27        SEND_VAR_EX                                              !5
         28        SEND_VAR_EX                                              !6
         29        SEND_VAR_EX                                              !8
         30        SEND_VAR_EX                                              !9
         31        SEND_VAR_EX                                              !10
         32        SEND_VAR_EX                                              !11
         33        SEND_VAR_EX                                              !12
         34        SEND_VAR_EX                                              !13
         35        DO_FCALL                                      0          
   55    36        INIT_METHOD_CALL                                         !0, 'execute'
         37        DO_FCALL                                      0          
   63    38        ASSIGN                                                   !7, null
   68    39        FETCH_R                      global              ~32     '_SERVER'
         40        FETCH_DIM_R                                      ~33     ~32, 'REQUEST_METHOD'
         41        IS_IDENTICAL                                             ~33, 'POST'
         42      > JMPZ                                                     ~34, ->71
   70    43    >   FETCH_R                      global              ~35     '_POST'
         44        FETCH_DIM_R                                      ~36     ~35, 'product_array'
         45      > FE_RESET_R                                       $37     ~36, ->70
         46    > > FE_FETCH_R                                               $37, !14, ->70
   72    47    > > FE_RESET_R                                       $38     !14, ->68
         48    > > FE_FETCH_R                                               $38, !3, ->68
   77    49    >   INIT_METHOD_CALL                                         !2, 'prepare'
         50        SEND_VAL_EX                                              '%0A++++++++++++++++INSERT+INTO%0A++++++++++++++++++++products%0A++++++++++++++++VALUES%0A++++++++++++++++++++%28%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%2C+%3F%29'
         51        DO_FCALL                                      0  $39     
         52        ASSIGN                                                   !0, $39
   83    53        INIT_METHOD_CALL                                         !0, 'bind_param'
         54        SEND_VAL_EX                                              'sssssssss'
         55        SEND_VAR_EX                                              !7
         56        SEND_VAR_EX                                              !5
         57        SEND_VAR_EX                                              !6
         58        SEND_VAR_EX                                              !8
         59        SEND_VAR_EX                                              !9
         60        SEND_VAR_EX                                              !10
         61        SEND_VAR_EX                                              !11
         62        SEND_VAR_EX                                              !12
         63        SEND_VAR_EX                                              !13
         64        DO_FCALL                                      0          
   94    65        INIT_METHOD_CALL                                         !0, 'execute'
         66        DO_FCALL                                      0          
   72    67      > JMP                                                      ->48
         68    >   FE_FREE                                                  $38
   70    69      > JMP                                                      ->46
         70    >   FE_FREE                                                  $37
   97    71    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.13 ms | 1404 KiB | 15 Q