Zend_Uri_Exception example


    public static function factory($uri = 'http', $className = null)
    {
        // Separate the scheme from the scheme-specific parts         $uri            = explode(':', $uri, 2);
        $scheme         = strtolower($uri[0]);
        $schemeSpecific = isset($uri[1]) === true ? $uri[1] : '';

        if (strlen($scheme) === 0) {
            throw new Zend_Uri_Exception('An empty string was supplied for the scheme');
        }

        // Security check: $scheme is used to load a class file, so only alphanumerics are allowed.         if (ctype_alnum($scheme) === false) {
            throw new Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted');
        }

        if ($className === null) {
            /** * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown. */
// If no scheme-specific part was supplied, the user intends to create         // a new URI with this object. No further parsing is required.         if (strlen($schemeSpecific) === 0) {
            return;
        }

        // Parse the scheme-specific URI parts into the instance variables.         $this->_parseUri($schemeSpecific);

        // Validate the URI         if ($this->valid() === false) {
            throw new Zend_Uri_Exception('Invalid URI supplied');
        }
    }

    /** * Creates a Zend_Uri_Http from the given string * * @param string $uri String to create URI from, must start with * 'http://' or 'https://' * @throws InvalidArgumentException When the given $uri is not a string or * does not start with http:// or https:// * @throws Zend_Uri_Exception When the given $uri is invalid * @return Zend_Uri_Http */
Home | Imprint | This part of the site doesn't use cookies.