JBZoo\Utils\Url::path PHP Method

path() public static method

Return the current path
public static path ( ) : string
return string
    public static function path()
    {
        $url = '';
        // Get the rest of the URL
        if (!Arr::key('REQUEST_URI', $_SERVER)) {
            // Microsoft IIS doesn't set REQUEST_URI by default
            $queryString = Arr::key('QUERY_STRING', $_SERVER, true);
            if ($queryString) {
                $url .= '?' . $queryString;
            }
        } else {
            $url .= $_SERVER['REQUEST_URI'];
        }
        return $url ? $url : null;
    }

Usage Example

Example #1
0
 public function testEmpty()
 {
     isSame(null, Url::root());
     isSame(null, Url::path());
     isSame(null, Url::current());
 }