-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest.php
28 lines (22 loc) · 895 Bytes
/
request.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
//Don't forget, because $_REQUEST is a different variable than $_GET and $_POST, it is treated as such in PHP -- modifying $_GET or $_POST elements at runtime will not affect the ellements in $_REQUEST, nor vice versa. e.g:
$_GET['foo'] = 'a';
$_POST['bar'] = 'b';
var_dump($_GET); // Element 'foo' is string(1) "a"
echo '<br>';
var_dump($_POST); // Element 'bar' is string(1) "b"
echo '<br>';
var_dump($_REQUEST); // Does not contain elements 'foo' or 'bar'
echo '<br>';
?>
<?php
//If you want to evaluate $_GET and $_POST variables by a single token without including $_COOKIE in the mix, use $_SERVER['REQUEST_METHOD'] to identify the method used and set up a switch block accordingly, e.g:
echo $_SERVER['REQUEST_METHOD'];
switch($_SERVER['REQUEST_METHOD'])
{
case 'GET': $the_request = &$_GET; break;
case 'POST': $the_request = &$_POST; break;
default:
}
echo $the_request;
?>