fork download
  1. <?php
  2. echo('$_GET, at start of script<br>');
  3. var_dump($_GET);
  4. echo('<hr>');
  5.  
  6. echo('unset($_GET), then dump it ()obviously, we expect an error<br>');
  7. unset($_GET);
  8. var_dump($_GET);
  9. echo('<hr>');
  10.  
  11. echo('Now, define $_GEt as an array, and add a few items, and validate it<br>');
  12. $_GET = array();
  13. $_GET['one'] = 1;
  14. $_GET['two plus two'] = 5;
  15. var_dump($_GET);
  16. echo('<hr>');
  17.  
  18. echo('Now, attempt to validate the $_GET<br>');
  19.  
  20. $fileters = array('one' => FILTER_VALIDATE_INT,
  21. 'two plus two' => FILTER_VALIDATE_INT,
  22. );
  23.  
  24. $validateGet = filter_var_array($_GET, $fileters, false);
  25. echo('Validation result = ');
  26. var_dump($validateGet);
Success #stdin #stdout #stderr 0.01s 52488KB
stdin
Standard input is empty
stdout
$_GET, at start of script<br>array(0) {
}
<hr>unset($_GET), then dump it ()obviously, we expect an error<br>NULL
<hr>Now, define $_GEt as an array, and add a few items, and validate it<br>array(2) {
  ["one"]=>
  int(1)
  ["two plus two"]=>
  int(5)
}
<hr>Now, attempt to validate the $_GET<br>Validation result = array(2) {
  ["one"]=>
  int(1)
  ["two plus two"]=>
  int(5)
}
stderr
PHP Notice:  Undefined variable: _GET in /home/NmnhQI/prog.php on line 8