⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 http.php

📁 Bug tracker, and reporter.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
    }    /**     * Returns the domain or host IP portion of the URL, or FALSE if none.     *     * @return string     */    public function getHost()    {        return strlen($this->_host) ? $this->_host : false;    }    /**     * Returns true if and only if the host string passes validation. If no host is passed,     * then the host contained in the instance variable is used.     *     * @param string $host     * @return boolean     * @uses Zend_Filter     */    public function validateHost($host = null)    {        if ($host === null) {            $host = $this->_host;        }        /**         * If the host is empty, then it is considered invalid         */        if (strlen($host) == 0) {            return false;        }        /**         * Check the host against the allowed values; delegated to Zend_Filter.         */        $validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);        return $validate->isValid($host);    }    /**     * Sets the host for the current URI, and returns the old host     *     * @param string $host     * @throws Zend_Uri_Exception     * @return string     */    public function setHost($host)    {        if (!$this->validateHost($host)) {	    require_once 'Zend/Uri/Exception.php';            throw new Zend_Uri_Exception("Host \"$host\" is not a valid HTTP host");        }        $oldHost = $this->_host;        $this->_host = $host;        return $oldHost;    }    /**     * Returns the TCP port, or FALSE if none.     *     * @return string     */    public function getPort()    {        return strlen($this->_port) ? $this->_port : false;    }    /**     * Returns true if and only if the TCP port string passes validation. If no port is passed,     * then the port contained in the instance variable is used.     *     * @param string $port     * @return boolean     */    public function validatePort($port = null)    {        if ($port === null) {            $port = $this->_port;        }        // If the port is empty, then it is considered valid        if (!strlen($port)) {            return true;        }        // Check the port against the allowed values        return ctype_digit((string)$port) && 1 <= $port && $port <= 65535;    }    /**     * Sets the port for the current URI, and returns the old port     *     * @param string $port     * @throws Zend_Uri_Exception     * @return string     */    public function setPort($port)    {        if (!$this->validatePort($port)) {	    require_once 'Zend/Uri/Exception.php';            throw new Zend_Uri_Exception("Port \"$port\" is not a valid HTTP port.");        }        $oldPort = $this->_port;        $this->_port = $port;        return $oldPort;    }    /**     * Returns the path and filename portion of the URL, or FALSE if none.     *     * @return string     */    public function getPath()    {        return strlen($this->_path) ? $this->_path : '/';    }    /**     * Returns true if and only if the path string passes validation. If no path is passed,     * then the path contained in the instance variable is used.     *     * @param string $path     * @throws Zend_Uri_Exception     * @return boolean     */    public function validatePath($path = null)    {        if ($path === null) {            $path = $this->_path;        }        /**         * If the path is empty, then it is considered valid         */        if (strlen($path) == 0) {            return true;        }        /**         * Determine whether the path is well-formed         */        $pattern = '/^' . $this->_regex['path'] . '$/';        $status = @preg_match($pattern, $path);        if ($status === false) {	    require_once 'Zend/Uri/Exception.php';            throw new Zend_Uri_Exception('Internal error: path validation failed');        }        return (boolean) $status;    }    /**     * Sets the path for the current URI, and returns the old path     *     * @param string $path     * @throws Zend_Uri_Exception     * @return string     */    public function setPath($path)    {        if (!$this->validatePath($path)) {	    require_once 'Zend/Uri/Exception.php';            throw new Zend_Uri_Exception("Path \"$path\" is not a valid HTTP path");        }        $oldPath = $this->_path;        $this->_path = $path;        return $oldPath;    }    /**     * Returns the query portion of the URL (after ?), or FALSE if none.     *     * @return string     */    public function getQuery()    {        return strlen($this->_query) ? $this->_query : false;    }    /**     * Returns true if and only if the query string passes validation. If no query is passed,     * then the query string contained in the instance variable is used.     *     * @param string $query     * @throws Zend_Uri_Exception     * @return boolean     */    public function validateQuery($query = null)    {        if ($query === null) {            $query = $this->_query;        }        // If query is empty, it is considered to be valid        if (strlen($query) == 0) {            return true;        }        /**         * Determine whether the query is well-formed         *         * @link http://www.faqs.org/rfcs/rfc2396.html         */        $pattern = '/^' . $this->_regex['uric'] . '*$/';        $status = @preg_match($pattern, $query);        if ($status === false) {	    require_once 'Zend/Uri/Exception.php';            throw new Zend_Uri_Exception('Internal error: query validation failed');        }        return $status == 1;    }    /**     * Set the query string for the current URI, and return the old query     * string This method accepts both strings and arrays.     *     * @param  string|array $query The query string or array     * @return string              Old query string     */    public function setQuery($query)    {        $oldQuery = $this->_query;                // If query is empty, set an empty string        if (empty($query)) {            $this->_query = '';            return $oldQuery;        }        // If query is an array, make a string out of it        if (is_array($query)) {            $query = http_build_query($query, '', '&');                // If it is a string, make sure it is valid. If not parse and encode it        } else {            $query = (string) $query;            if (! $this->validateQuery($query)) {                parse_str($query, $query_array);                $query = http_build_query($query_array, '', '&');               }        }        // Make sure the query is valid, and set it        if (! $this->validateQuery($query)) {	    require_once 'Zend/Uri/Exception.php';            throw new Zend_Uri_Exception("'$query' is not a valid query string");        }                $this->_query = $query;                return $oldQuery;    }    /**     * Returns the fragment portion of the URL (after #), or FALSE if none.     *     * @return string|false     */    public function getFragment()    {        return strlen($this->_fragment) ? $this->_fragment : false;    }    /**     * Returns true if and only if the fragment passes validation. If no fragment is passed,     * then the fragment contained in the instance variable is used.     *     * @param string $fragment     * @throws Zend_Uri_Exception     * @return boolean     */    public function validateFragment($fragment = null)    {        if ($fragment === null) {            $fragment = $this->_fragment;        }        // If fragment is empty, it is considered to be valid        if (strlen($fragment) == 0) {            return true;        }        /**         * Determine whether the fragment is well-formed         *         * @link http://www.faqs.org/rfcs/rfc2396.html         */        $pattern = '/^' . $this->_regex['uric'] . '*$/';        $status = @preg_match($pattern, $fragment);        if ($status === false) {	    require_once 'Zend/Uri/Exception.php';            throw new Zend_Uri_Exception('Internal error: fragment validation failed');        }        return (boolean) $status;    }    /**     * Sets the fragment for the current URI, and returns the old fragment     *     * @param string $fragment     * @throws Zend_Uri_Exception     * @return string     */    public function setFragment($fragment)    {        if (!$this->validateFragment($fragment)) {	    require_once 'Zend/Uri/Exception.php';            throw new Zend_Uri_Exception("Fragment \"$fragment\" is not a valid HTTP fragment");        }        $oldFragment = $this->_fragment;        $this->_fragment = $fragment;        return $oldFragment;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -