public static function parseUrl($key = null) {

		if(null !== $key && false === is_string($key)) {
  			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
  		}

		$url 	= [];
		$types 	= [

			'host' 		=> 'HTTP_HOST',
			'port' 		=> 'SERVER_PORT',
			'protocol' 	=> 'REQUEST_SCHEME',
			'path'		=> 'REQUEST_URI',
			'query' 	=> 'QUERY_STRING'
		];

		foreach($types as $type => $value) {

			if(true === isset($_SERVER[$value])) {
				$url[$type] = $_SERVER[$value];
			}
		}

		if(true === isset($url['path'], $url['query']) && '' !== $url['query']) {
			$url['path'] = str_replace('?' . $url['query'], '', $url['path']);
		}

		if(true === isset($url[$key])) {
			return $url[$key];
		}

		if(null === $key) {
			return $url;
		}

		return null;
	}
public static function parseUrl($key = null) {

		if(null !== $key && false === is_string($key)) {
  			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
  		}

		$url 	= [];
		$types 	= [

			'host' 		=> 'HTTP_HOST',
			'port' 		=> 'SERVER_PORT',
			'protocol' 	=> 'REQUEST_SCHEME',
			'path'		=> 'REQUEST_URI',
			'query' 	=> 'QUERY_STRING'
		];

		foreach($types as $type => $value) {

			if(true === isset($_SERVER[$value])) {
				$url[$type] = $_SERVER[$value];
			}
		}

		if(true === isset($url['path'], $url['query']) && '' !== $url['query']) {
			$url['path'] = str_replace('?' . $url['query'], '', $url['path']);
		}

		if(true === isset($url[$key])) {
			return $url[$key];
		}

		if(null === $key) {
			return $url;
		}

		return null;
	}
public static function parseUrl ( $ key = null ) { if ( null !== $ key && false === is_string ( $ key ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ key ) ) , E_USER_ERROR ) ; } $ url = [ ] ; $ types = [ 'host' => 'HTTP_HOST' , 'port' => 'SERVER_PORT' , 'protocol' => 'REQUEST_SCHEME' , 'path' => 'REQUEST_URI' , 'query' => 'QUERY_STRING' ] ; foreach ( $ types as $ type => $ value ) { if ( true === isset ( $ _SERVER [ $ value ] ) ) { $ url [ $ type ] = $ _SERVER [ $ value ] ; } } if ( true === isset ( $ url [ 'path' ] , $ url [ 'query' ] ) && '' !== $ url [ 'query' ] ) { $ url [ 'path' ] = str_replace ( '?' . $ url [ 'query' ] , '' , $ url [ 'path' ] ) ; } if ( true === isset ( $ url [ $ key ] ) ) { return $ url [ $ key ] ; } if ( null === $ key ) { return $ url ; } return null ; }
Returns parsed url by giving an option key for only the value of that key to return
@param string $key
@return array|string|null
Returns parsed url by giving an option key for only the value of that key to return