3v4l.org

run code in 300+ PHP versions simultaneously
<?php include_once 'dbconfig.php'; $method = $_SERVER['REQUEST_METHOD']; switch($method) { case 'POST': $data = json_decode($_POST['params']); $name = $data['name']; $sql_query = "INSERT INTO person(name) VALUES('$name')"; $result = mysqli_query($link, $sql_query); break; case 'GET': $uriParts = spliti ("/", $_SERVER['REQUEST_URI']); $id = end($uriParts); $sql_query="SELECT * FROM person WHERE id=".$id; $result_set=mysqli_query($link, $sql_query); $rows = array(); while($r = mysqli_fetch_assoc($result_set)) { $rows[] = $r; } break; } header('Content-type: application/json'); echo json_encode($rows);
Finding entry points
Branch analysis from position: 0
4 jumps found. (Code = 188) Position 1 = 10, Position 2 = 28, Position 3 = 57, Position 4 = 5
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 49
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 49
Branch analysis from position: 56
Branch analysis from position: 49
Branch analysis from position: 57
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 28
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 28
Branch analysis from position: 10
filename:       /in/rvn2F
function name:  (null)
number of ops:  65
compiled vars:  !0 = $method, !1 = $data, !2 = $name, !3 = $sql_query, !4 = $result, !5 = $link, !6 = $uriParts, !7 = $id, !8 = $result_set, !9 = $rows, !10 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INCLUDE_OR_EVAL                                          'dbconfig.php', INCLUDE_ONCE
    4     1        FETCH_R                      global              ~12     '_SERVER'
          2        FETCH_DIM_R                                      ~13     ~12, 'REQUEST_METHOD'
          3        ASSIGN                                                   !0, ~13
    6     4      > SWITCH_STRING                                            !0, [ 'POST':->10, 'GET':->28, ], ->57
    7     5    >   IS_EQUAL                                                 !0, 'POST'
          6      > JMPNZ                                                    ~15, ->10
   14     7    >   IS_EQUAL                                                 !0, 'GET'
          8      > JMPNZ                                                    ~15, ->28
          9    > > JMP                                                      ->57
    8    10    >   INIT_FCALL                                               'json_decode'
         11        FETCH_R                      global              ~16     '_POST'
         12        FETCH_DIM_R                                      ~17     ~16, 'params'
         13        SEND_VAL                                                 ~17
         14        DO_ICALL                                         $18     
         15        ASSIGN                                                   !1, $18
    9    16        FETCH_DIM_R                                      ~20     !1, 'name'
         17        ASSIGN                                                   !2, ~20
   10    18        ROPE_INIT                                     3  ~23     'INSERT+INTO+person%28name%29+VALUES%28%27'
         19        ROPE_ADD                                      1  ~23     ~23, !2
         20        ROPE_END                                      2  ~22     ~23, '%27%29'
         21        ASSIGN                                                   !3, ~22
   11    22        INIT_FCALL_BY_NAME                                       'mysqli_query'
         23        SEND_VAR_EX                                              !5
         24        SEND_VAR_EX                                              !3
         25        DO_FCALL                                      0  $26     
         26        ASSIGN                                                   !4, $26
   12    27      > JMP                                                      ->57
   15    28    >   INIT_FCALL_BY_NAME                                       'spliti'
         29        SEND_VAL_EX                                              '%2F'
         30        CHECK_FUNC_ARG                                           
         31        FETCH_FUNC_ARG               global              $28     '_SERVER'
         32        FETCH_DIM_FUNC_ARG                               $29     $28, 'REQUEST_URI'
         33        SEND_FUNC_ARG                                            $29
         34        DO_FCALL                                      0  $30     
         35        ASSIGN                                                   !6, $30
   16    36        INIT_FCALL                                               'end'
         37        SEND_REF                                                 !6
         38        DO_ICALL                                         $32     
         39        ASSIGN                                                   !7, $32
   17    40        CONCAT                                           ~34     'SELECT+%2A+FROM+person+WHERE+id%3D', !7
         41        ASSIGN                                                   !3, ~34
   18    42        INIT_FCALL_BY_NAME                                       'mysqli_query'
         43        SEND_VAR_EX                                              !5
         44        SEND_VAR_EX                                              !3
         45        DO_FCALL                                      0  $36     
         46        ASSIGN                                                   !8, $36
   19    47        ASSIGN                                                   !9, <array>
   20    48      > JMP                                                      ->51
   21    49    >   ASSIGN_DIM                                               !9
         50        OP_DATA                                                  !10
   20    51    >   INIT_FCALL_BY_NAME                                       'mysqli_fetch_assoc'
         52        SEND_VAR_EX                                              !8
         53        DO_FCALL                                      0  $40     
         54        ASSIGN                                           ~41     !10, $40
         55      > JMPNZ                                                    ~41, ->49
   23    56    > > JMP                                                      ->57
   26    57    >   INIT_FCALL                                               'header'
         58        SEND_VAL                                                 'Content-type%3A+application%2Fjson'
         59        DO_ICALL                                                 
   27    60        INIT_FCALL                                               'json_encode'
         61        SEND_VAR                                                 !9
         62        DO_ICALL                                         $43     
         63        ECHO                                                     $43
         64      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.05 ms | 1400 KiB | 21 Q