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
![]() |
|||
32 | |||
33 | } |
||
34 | ?> |
||
35 |