-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequestmethods.php
43 lines (33 loc) · 1.04 KB
/
requestmethods.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* RequestMethods class is quite simple. It has methods for returning get/post/server variables, based on a key.
* If that key is not present, the default value will be returned. We use these methods to return our posted form data to the controller.
*
* @author Faizan Ayubi
*/
namespace Framework {
class RequestMethods {
private function __construct() {
// do nothing
}
private function __clone() {
// do nothing
}
public static function get($key, $default = "") {
if (!empty($_GET[$key])) {
return $_GET[$key];
}
return $default;
}
public static function post($key, $default = "") {
if (!empty($_POST[$key])) {
return $_POST[$key];
} return $default;
}
public static function server($key, $default = "") {
if (!empty($_SERVER[$key])) {
return $_SERVER[$key];
} return $default;
}
}
}