lengthOfRoot = strlen('knowyourfood') + 1; } public function getPath(){//identificam din URL pe pagina trebuie accesata $path = $_SERVER['REQUEST_URI']; $path = substr($path, $this->lengthOfRoot); $position = strpos($path, '?'); if(!$position){ return $path; } return substr($path, 0, $position); } public function method(){ return strtolower($_SERVER['REQUEST_METHOD']); } public function isGet(){ return $this->method() === 'get'; } public function isPost(){ return $this->method() === 'post'; } //bazat pe tipul de request, accesam tuplele key/value pentru a identifica body ul requestului public function getBody(){ $body = []; if($this->method() === 'get'){ foreach($_GET as $key => $value){ $body[$key] = filter_input(INPUT_GET, $key, FILTER_SANITIZE_SPECIAL_CHARS); } } if($this->method() === 'post'){ foreach($_POST as $key => $value){ $body[$key] = filter_input(INPUT_POST, $key, FILTER_SANITIZE_SPECIAL_CHARS); } } return $body; } }