xezzus /
humanity
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | namespace humanity; |
||
| 3 | |||
| 4 | class Uri { |
||
| 5 | |||
| 6 | private $requestUri = ''; |
||
| 7 | |||
| 8 | public function __construct(){ |
||
| 9 | $this->requestUri = $_SERVER['REQUEST_URI']; |
||
| 10 | $tmp = explode('/',$this->requiestUri); |
||
| 11 | foreach($tmp as $key=>$value){ |
||
| 12 | $value = trim($value); |
||
| 13 | if(empty($value)) unset($tmp[$key]); |
||
| 14 | else $tmp[$key] = $value; |
||
| 15 | } |
||
| 16 | $tmp = array_values($tmp); |
||
| 17 | $this->requestUri = $tmp; |
||
| 18 | } |
||
| 19 | |||
| 20 | public function full(){ |
||
| 21 | return '/'.implode('/',$this->requestUri); |
||
| 22 | } |
||
| 23 | |||
| 24 | public function part($number){ |
||
| 25 | if(isset($this->requestUri[$number])) return (string) urldecode($this->requestUri[$number]); |
||
| 26 | else return ''; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function host(){ |
||
| 30 | return parse_url('http://'.$_SERVER['HTTP_HOST'])['host'] |
||
| 31 | } |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 32 | |||
| 33 | } |
||
| 34 | ?> |
||
|
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. Loading history...
|
|||
| 35 |