3v4l.org

run code in 300+ PHP versions simultaneously
<?php header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: access"); header("Access-Control-Allow-Methods: GET"); header("Access-Control-Allow-Credentials: true"); header("Content-Type: application/json; charset=UTF-8"); function getResponse() { if (!isset($_GET['id']) || !ctype_digit($_GET['id'])) { return ['message' => 'Missing/Invalid identifier provided']; } include_once('config_setup.php'); $sql = "SELECT id, caption, filename, description2 FROM photographs WHERE id = " . $_GET['id']; $result = mysqli_query($db, $sql); if (!$result) { return ['message' => 'Please contact the dev team.']; } $photo = mysqli_fetch_assoc($result); if (!$photo) { return ['message' => 'No product.']; } $url = 'http://localhost/photo_gallery/public/files/images/'; $allowed = '<div><img><h1><h2><p><br><strong><em><ul><li><table><td><tr><th><tbody>'; return [ 'id' => urlencode(htmlspecialchars($photo['id'])), 'caption' => htmlspecialchars($photo['caption']), 'filename' => $url . htmlspecialchars($photo['filename']), 'description2' => strip_tags($photo['description2'], $allowed), ]; } $response = getResponse(); http_response_code(isset($response['message']) ? 404 : 200); echo json_encode($response);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g9V0T
function name:  (null)
number of ops:  31
compiled vars:  !0 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'header'
          1        SEND_VAL                                                 'Access-Control-Allow-Origin%3A+%2A'
          2        DO_ICALL                                                 
    4     3        INIT_FCALL                                               'header'
          4        SEND_VAL                                                 'Access-Control-Allow-Headers%3A+access'
          5        DO_ICALL                                                 
    5     6        INIT_FCALL                                               'header'
          7        SEND_VAL                                                 'Access-Control-Allow-Methods%3A+GET'
          8        DO_ICALL                                                 
    6     9        INIT_FCALL                                               'header'
         10        SEND_VAL                                                 'Access-Control-Allow-Credentials%3A+true'
         11        DO_ICALL                                                 
    7    12        INIT_FCALL                                               'header'
         13        SEND_VAL                                                 'Content-Type%3A+application%2Fjson%3B+charset%3DUTF-8'
         14        DO_ICALL                                                 
   33    15        INIT_FCALL                                               'getresponse'
         16        DO_FCALL                                      0  $6      
         17        ASSIGN                                                   !0, $6
   34    18        INIT_FCALL                                               'http_response_code'
         19        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'message'
         20      > JMPZ                                                     ~8, ->23
         21    >   QM_ASSIGN                                        ~9      404
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~9      200
         24    >   SEND_VAL                                                 ~9
         25        DO_ICALL                                                 
   35    26        INIT_FCALL                                               'json_encode'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $11     
         29        ECHO                                                     $11
         30      > RETURN                                                   1

Function getresponse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/g9V0T
function name:  getResponse
number of ops:  62
compiled vars:  !0 = $sql, !1 = $result, !2 = $db, !3 = $photo, !4 = $url, !5 = $allowed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_IS                                         ~6      '_GET'
          1        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      ~6, 'id'
          2        BOOL_NOT                                         ~8      ~7
          3      > JMPNZ_EX                                         ~8      ~8, ->11
          4    >   INIT_FCALL                                               'ctype_digit'
          5        FETCH_R                      global              ~9      '_GET'
          6        FETCH_DIM_R                                      ~10     ~9, 'id'
          7        SEND_VAL                                                 ~10
          8        DO_ICALL                                         $11     
          9        BOOL_NOT                                         ~12     $11
         10        BOOL                                             ~8      ~12
         11    > > JMPZ                                                     ~8, ->13
   11    12    > > RETURN                                                   <array>
   13    13    >   INCLUDE_OR_EVAL                                          'config_setup.php', INCLUDE_ONCE
   14    14        FETCH_R                      global              ~14     '_GET'
         15        FETCH_DIM_R                                      ~15     ~14, 'id'
         16        CONCAT                                           ~16     'SELECT+id%2C+caption%2C+filename%2C+description2+FROM+photographs+WHERE+id+%3D+', ~15
         17        ASSIGN                                                   !0, ~16
   15    18        INIT_FCALL_BY_NAME                                       'mysqli_query'
         19        SEND_VAR_EX                                              !2
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0  $18     
         22        ASSIGN                                                   !1, $18
   16    23        BOOL_NOT                                         ~20     !1
         24      > JMPZ                                                     ~20, ->26
   17    25    > > RETURN                                                   <array>
   19    26    >   INIT_FCALL_BY_NAME                                       'mysqli_fetch_assoc'
         27        SEND_VAR_EX                                              !1
         28        DO_FCALL                                      0  $21     
         29        ASSIGN                                                   !3, $21
   20    30        BOOL_NOT                                         ~23     !3
         31      > JMPZ                                                     ~23, ->33
   21    32    > > RETURN                                                   <array>
   23    33    >   ASSIGN                                                   !4, 'http%3A%2F%2Flocalhost%2Fphoto_gallery%2Fpublic%2Ffiles%2Fimages%2F'
   24    34        ASSIGN                                                   !5, '%3Cdiv%3E%3Cimg%3E%3Ch1%3E%3Ch2%3E%3Cp%3E%3Cbr%3E%3Cstrong%3E%3Cem%3E%3Cul%3E%3Cli%3E%3Ctable%3E%3Ctd%3E%3Ctr%3E%3Cth%3E%3Ctbody%3E'
   26    35        INIT_FCALL                                               'urlencode'
         36        INIT_FCALL                                               'htmlspecialchars'
         37        FETCH_DIM_R                                      ~26     !3, 'id'
         38        SEND_VAL                                                 ~26
         39        DO_ICALL                                         $27     
         40        SEND_VAR                                                 $27
         41        DO_ICALL                                         $28     
         42        INIT_ARRAY                                       ~29     $28, 'id'
   27    43        INIT_FCALL                                               'htmlspecialchars'
         44        FETCH_DIM_R                                      ~30     !3, 'caption'
         45        SEND_VAL                                                 ~30
         46        DO_ICALL                                         $31     
         47        ADD_ARRAY_ELEMENT                                ~29     $31, 'caption'
   28    48        INIT_FCALL                                               'htmlspecialchars'
         49        FETCH_DIM_R                                      ~32     !3, 'filename'
         50        SEND_VAL                                                 ~32
         51        DO_ICALL                                         $33     
         52        CONCAT                                           ~34     !4, $33
         53        ADD_ARRAY_ELEMENT                                ~29     ~34, 'filename'
   29    54        INIT_FCALL                                               'strip_tags'
         55        FETCH_DIM_R                                      ~35     !3, 'description2'
         56        SEND_VAL                                                 ~35
         57        SEND_VAR                                                 !5
         58        DO_ICALL                                         $36     
         59        ADD_ARRAY_ELEMENT                                ~29     $36, 'description2'
         60      > RETURN                                                   ~29
   31    61*     > RETURN                                                   null

End of function getresponse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.96 ms | 952 KiB | 29 Q