fork download
  1. <html>
  2. <body>
  3. <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  4. Select options:
  5. <input type="radio" value="push" name="d1">Push</input>
  6. <input type="radio" value="pop" name="d1">Pop</input>
  7. <input type="radio" value="display" name="d1">Display</input>
  8. <input type="submit">
  9. </form>
  10. <?php
  11. echo "Index ARRAY";
  12. $a = array(1,2,3,4,5,6,7);
  13. print_r($a);
  14. print"<br>";
  15. if($_SERVER["REQUEST_METHOD"] == "POST")
  16. {
  17. $opt = $_POST['d1'];
  18. if($opt == 'push')
  19. {
  20. array_push($a,11);
  21. print_r($a);
  22. }
  23. else if($opt == 'pop')
  24. {
  25. print_r($a);
  26. }
  27. else if($opt == 'display')
  28. {
  29. print_r($a);
  30. }
  31. }
  32. ?>
Success #stdin #stdout #stderr 0.02s 26252KB
stdin
Standard input is empty
stdout
<html>
<body>
<form method="POST" action="prog.php">
Select options:
<input type="radio" value="push" name="d1">Push</input>
<input type="radio" value="pop" name="d1">Pop</input>
<input type="radio" value="display" name="d1">Display</input>
<input type="submit">
</form>
Index ARRAYArray
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
    [6] => 7
)
<br>
stderr
PHP Notice:  Undefined index: REQUEST_METHOD in /home/TUU0IW/prog.php on line 15