3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE HTML> <html> <head> </head> <body> <?php // define variables and set to empty values $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = test_input($_POST["name"]); $email = test_input($_POST["email"]); $website = test_input($_POST["website"]); $comment = test_input($_POST["comment"]); $gender = test_input($_POST["gender"]); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>PHP Form Validation Example</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Name: <input type="text" name="name"> <br><br> E-mail: <input type="text" name="email"> <br><br> Website: <input type="text" name="website"> <br><br> Comment: <textarea name="comment" rows="5" cols="40"></textarea> <br><br> Gender: <input type="radio" name="gender" value="female">Female <input type="radio" name="gender" value="male">Male <br><br> <input type="submit" name="submit" value="Submit"> </form> <?php echo "<h2>Your Input:</h2>"; echo $name; echo "<br>"; echo $email; echo "<br>"; echo $website; echo "<br>"; echo $comment; echo "<br>"; echo $gender; ?> </body> </html>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 45
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
filename:       /in/29cNV
function name:  (null)
number of ops:  65
compiled vars:  !0 = $name, !1 = $email, !2 = $gender, !3 = $comment, !4 = $website
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3C%21DOCTYPE+HTML%3E++%0A%3Chtml%3E%0A%3Chead%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E++%0A%0A'
    9     1        ASSIGN                                           ~5      !4, ''
          2        ASSIGN                                           ~6      !3, ~5
          3        ASSIGN                                           ~7      !2, ~6
          4        ASSIGN                                           ~8      !1, ~7
          5        ASSIGN                                                   !0, ~8
   11     6        FETCH_R                      global              ~10     '_SERVER'
          7        FETCH_DIM_R                                      ~11     ~10, 'REQUEST_METHOD'
          8        IS_EQUAL                                                 ~11, 'POST'
          9      > JMPZ                                                     ~12, ->45
   12    10    >   INIT_FCALL_BY_NAME                                       'test_input'
         11        CHECK_FUNC_ARG                                           
         12        FETCH_FUNC_ARG               global              $13     '_POST'
         13        FETCH_DIM_FUNC_ARG                               $14     $13, 'name'
         14        SEND_FUNC_ARG                                            $14
         15        DO_FCALL                                      0  $15     
         16        ASSIGN                                                   !0, $15
   13    17        INIT_FCALL_BY_NAME                                       'test_input'
         18        CHECK_FUNC_ARG                                           
         19        FETCH_FUNC_ARG               global              $17     '_POST'
         20        FETCH_DIM_FUNC_ARG                               $18     $17, 'email'
         21        SEND_FUNC_ARG                                            $18
         22        DO_FCALL                                      0  $19     
         23        ASSIGN                                                   !1, $19
   14    24        INIT_FCALL_BY_NAME                                       'test_input'
         25        CHECK_FUNC_ARG                                           
         26        FETCH_FUNC_ARG               global              $21     '_POST'
         27        FETCH_DIM_FUNC_ARG                               $22     $21, 'website'
         28        SEND_FUNC_ARG                                            $22
         29        DO_FCALL                                      0  $23     
         30        ASSIGN                                                   !4, $23
   15    31        INIT_FCALL_BY_NAME                                       'test_input'
         32        CHECK_FUNC_ARG                                           
         33        FETCH_FUNC_ARG               global              $25     '_POST'
         34        FETCH_DIM_FUNC_ARG                               $26     $25, 'comment'
         35        SEND_FUNC_ARG                                            $26
         36        DO_FCALL                                      0  $27     
         37        ASSIGN                                                   !3, $27
   16    38        INIT_FCALL_BY_NAME                                       'test_input'
         39        CHECK_FUNC_ARG                                           
         40        FETCH_FUNC_ARG               global              $29     '_POST'
         41        FETCH_DIM_FUNC_ARG                               $30     $29, 'gender'
         42        SEND_FUNC_ARG                                            $30
         43        DO_FCALL                                      0  $31     
         44        ASSIGN                                                   !2, $31
   26    45    >   ECHO                                                     '%0A%3Ch2%3EPHP+Form+Validation+Example%3C%2Fh2%3E%0A%3Cform+method%3D%22post%22+action%3D%22'
   28    46        INIT_FCALL                                               'htmlspecialchars'
         47        FETCH_R                      global              ~33     '_SERVER'
         48        FETCH_DIM_R                                      ~34     ~33, 'PHP_SELF'
         49        SEND_VAL                                                 ~34
         50        DO_ICALL                                         $35     
         51        ECHO                                                     $35
         52        ECHO                                                     '%22%3E++%0A++Name%3A+%3Cinput+type%3D%22text%22+name%3D%22name%22%3E%0A++%3Cbr%3E%3Cbr%3E%0A++E-mail%3A+%3Cinput+type%3D%22text%22+name%3D%22email%22%3E%0A++%3Cbr%3E%3Cbr%3E%0A++Website%3A+%3Cinput+type%3D%22text%22+name%3D%22website%22%3E%0A++%3Cbr%3E%3Cbr%3E%0A++Comment%3A+%3Ctextarea+name%3D%22comment%22+rows%3D%225%22+cols%3D%2240%22%3E%3C%2Ftextarea%3E%0A++%3Cbr%3E%3Cbr%3E%0A++Gender%3A%0A++%3Cinput+type%3D%22radio%22+name%3D%22gender%22+value%3D%22female%22%3EFemale%0A++%3Cinput+type%3D%22radio%22+name%3D%22gender%22+value%3D%22male%22%3EMale%0A++%3Cbr%3E%3Cbr%3E%0A++%3Cinput+type%3D%22submit%22+name%3D%22submit%22+value%3D%22Submit%22%3E++%0A%3C%2Fform%3E%0A%0A'
   45    53        ECHO                                                     '%3Ch2%3EYour+Input%3A%3C%2Fh2%3E'
   46    54        ECHO                                                     !0
   47    55        ECHO                                                     '%3Cbr%3E'
   48    56        ECHO                                                     !1
   49    57        ECHO                                                     '%3Cbr%3E'
   50    58        ECHO                                                     !4
   51    59        ECHO                                                     '%3Cbr%3E'
   52    60        ECHO                                                     !3
   53    61        ECHO                                                     '%3Cbr%3E'
   54    62        ECHO                                                     !2
   56    63        ECHO                                                     '%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   58    64      > RETURN                                                   1

Function test_input:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/29cNV
function name:  test_input
number of ops:  15
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   21     5        INIT_FCALL                                               'stripslashes'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $3      
          8        ASSIGN                                                   !0, $3
   22     9        INIT_FCALL                                               'htmlspecialchars'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        ASSIGN                                                   !0, $5
   23    13      > RETURN                                                   !0
   24    14*     > RETURN                                                   null

End of function test_input

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.51 ms | 1408 KiB | 19 Q