12345678910111213141516171819202122 |
- <?php
- require_once "../libs/Url.php";
- class UrlParser {
- public static function getInstance() {
- return new UrlParser();
- }
- public function getUrlData() {
- $data = array();
- $urlData = explode("?", $_SERVER['REQUEST_URI']);
- $path = explode("/", trim($urlData[0], "/"));
- $queryParams = array();
-
- if(isset($urlData[1])) {
- $queryParamData = explode("&", $urlData[1]);
- foreach($queryParamData as $string) {
- $singleParam = explode("=", $string);
- $queryParams[$singleParam[0]] = isset($singleParam[1]) ? $singleParam[1] : true;
- }
- }
- return new Url($path, $queryParams);
- }
- }
|