Nette\Http\Url::__construct PHP Метод

__construct() публичный Метод

public __construct ( $url = NULL )
    public function __construct($url = NULL)
    {
        if (is_string($url)) {
            $p = @parse_url($url);
            // @ - is escalated to exception
            if ($p === FALSE) {
                throw new Nette\InvalidArgumentException("Malformed or unsupported URI '{$url}'.");
            }
            $this->scheme = isset($p['scheme']) ? $p['scheme'] : '';
            $this->port = isset($p['port']) ? $p['port'] : NULL;
            $this->host = isset($p['host']) ? rawurldecode($p['host']) : '';
            $this->user = isset($p['user']) ? rawurldecode($p['user']) : '';
            $this->password = isset($p['pass']) ? rawurldecode($p['pass']) : '';
            $this->setPath(isset($p['path']) ? $p['path'] : '');
            $this->setQuery(isset($p['query']) ? $p['query'] : []);
            $this->fragment = isset($p['fragment']) ? rawurldecode($p['fragment']) : '';
        } elseif ($url instanceof self) {
            foreach ($this as $key => $val) {
                $this->{$key} = $url->{$key};
            }
        }
    }

Usage Example

Пример #1
0
 public function __construct($url = NULL)
 {
     parent::__construct($url);
     \parse_str($this->getQuery(), $this->queryArray);
 }