3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE html> <?php global $db; $sqliteerror = null; try{ $db = new PDO('sqlite:mysqlitedb.sqlite3'); } catch(Exception $e){ echo htmlentities($e->getMessage()); echo "<br><br><br>"; die('Error opening or creating new sqlite DB. Check write permissions for '.dirname(__FILE__)); } //Save if(isset($_POST['answer']) && trim($_POST['answer'])){ $sql = 'INSERT INTO survey (answer) VALUES (\''.$_POST['answer'].'\')'; $db->query($sql); } ?> <html> <head> <title></title> </head> <body> <fieldset> <legend>SURVEY: What is the best food?</legend> <form method="POST"> <label>Answer: <input type="text" name="answer"></label> <input type="submit"> </form> </fieldset> <fieldset> <legend>SURVEY: Previous Answers</legend> <?php $sql = 'SELECT COUNT(*) as x, `answer` FROM survey WHERE `answer` != \'\' GROUP BY `answer`'; foreach ($db->query($sql) as $row) { echo $row['x'] . "x ".$row['answer'].'<br>'; } ?> </fieldset> </body> </html>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 39
Branch analysis from position: 31
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 53
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 53
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
Branch analysis from position: 39
Branch analysis from position: 30
Found catch point at position: 8
Branch analysis from position: 8
2 jumps found. (Code = 107) Position 1 = 9, Position 2 = -2
Branch analysis from position: 9
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/1dpJI
function name:  (null)
number of ops:  56
compiled vars:  !0 = $db, !1 = $sqliteerror, !2 = $e, !3 = $sql, !4 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3C%21DOCTYPE+html%3E%0A'
    4     1        BIND_GLOBAL                                              !0, 'db'
    5     2        ASSIGN                                                   !1, null
    7     3        NEW                                              $6      'PDO'
          4        SEND_VAL_EX                                              'sqlite%3Amysqlitedb.sqlite3'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $6
          7      > JMP                                                      ->21
    9     8  E > > CATCH                                       last         'Exception'
   10     9    >   INIT_FCALL                                               'htmlentities'
         10        INIT_METHOD_CALL                                         !2, 'getMessage'
         11        DO_FCALL                                      0  $9      
         12        SEND_VAR                                                 $9
         13        DO_ICALL                                         $10     
         14        ECHO                                                     $10
   11    15        ECHO                                                     '%3Cbr%3E%3Cbr%3E%3Cbr%3E'
   12    16        INIT_FCALL                                               'dirname'
         17        SEND_VAL                                                 '%2Fin%2F1dpJI'
         18        DO_ICALL                                         $11     
         19        CONCAT                                           ~12     'Error+opening+or+creating+new+sqlite+DB.++Check+write+permissions+for+', $11
         20      > EXIT                                                     ~12
   16    21    >   FETCH_IS                                         ~13     '_POST'
         22        ISSET_ISEMPTY_DIM_OBJ                         0  ~14     ~13, 'answer'
         23      > JMPZ_EX                                          ~14     ~14, ->30
         24    >   INIT_FCALL                                               'trim'
         25        FETCH_R                      global              ~15     '_POST'
         26        FETCH_DIM_R                                      ~16     ~15, 'answer'
         27        SEND_VAL                                                 ~16
         28        DO_ICALL                                         $17     
         29        BOOL                                             ~14     $17
         30    > > JMPZ                                                     ~14, ->39
   17    31    >   FETCH_R                      global              ~18     '_POST'
         32        FETCH_DIM_R                                      ~19     ~18, 'answer'
         33        CONCAT                                           ~20     'INSERT+INTO+survey+%28answer%29+VALUES+%28%27', ~19
         34        CONCAT                                           ~21     ~20, '%27%29'
         35        ASSIGN                                                   !3, ~21
   18    36        INIT_METHOD_CALL                                         !0, 'query'
         37        SEND_VAR_EX                                              !3
         38        DO_FCALL                                      0          
   21    39    >   ECHO                                                     '%3Chtml%3E%0A%09%3Chead%3E%0A%09%09%3Ctitle%3E%3C%2Ftitle%3E%0A%09%3C%2Fhead%3E%0A%09%3Cbody%3E%0A%09%09%3Cfieldset%3E%0A%09%09%09%3Clegend%3ESURVEY%3A+What+is+the+best+food%3F%3C%2Flegend%3E%0A%09%09%09%3Cform+method%3D%22POST%22%3E%0A%09%09%09%09%3Clabel%3EAnswer%3A+%3Cinput+type%3D%22text%22+name%3D%22answer%22%3E%3C%2Flabel%3E%0A%09%09%09%09%3Cinput+type%3D%22submit%22%3E%0A%09%09%09%3C%2Fform%3E%0A%09%09%3C%2Ffieldset%3E%0A%09%09%0A%09%09%3Cfieldset%3E%0A%09%09%09%3Clegend%3ESURVEY%3A+Previous+Answers%3C%2Flegend%3E%0A%09%09%09'
   37    40        ASSIGN                                                   !3, 'SELECT+COUNT%28%2A%29+as+x%2C+%60answer%60+FROM+survey+WHERE+%60answer%60+%21%3D+%27%27+GROUP+BY+%60answer%60'
   38    41        INIT_METHOD_CALL                                         !0, 'query'
         42        SEND_VAR_EX                                              !3
         43        DO_FCALL                                      0  $25     
         44      > FE_RESET_R                                       $26     $25, ->53
         45    > > FE_FETCH_R                                               $26, !4, ->53
   39    46    >   FETCH_DIM_R                                      ~27     !4, 'x'
         47        CONCAT                                           ~28     ~27, 'x+'
         48        FETCH_DIM_R                                      ~29     !4, 'answer'
         49        CONCAT                                           ~30     ~28, ~29
         50        CONCAT                                           ~31     ~30, '%3Cbr%3E'
         51        ECHO                                                     ~31
   38    52      > JMP                                                      ->45
         53    >   FE_FREE                                                  $26
   42    54        ECHO                                                     '%09%09%3C%2Ffieldset%3E%0A%09%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   44    55      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.82 ms | 1400 KiB | 19 Q