Uri/Http.php
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Uri
- Version
- $Id$
\Zend_Uri_Http
- Parent(s)
- \Zend_Uri
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Uses
Constants
Properties
array $_regex = array()
array()
Details- Type
- array
Methods
__construct(string $scheme, string $schemeSpecific = '') : void
Constructor accepts a string $scheme (e.g., http, https) and a scheme-specific part of the URI (e.g., example.com/path/to/resource?query=param#fragment)
Name | Type | Description |
---|---|---|
$scheme | string | The scheme of the URI |
$schemeSpecific | string | The scheme-specific part of the URI |
Exception | Description |
---|---|
\Zend_Uri_Exception | When the URI is not valid |
_parseUri(string $schemeSpecific) : void
Parse the scheme-specific portion of the URI and place its parts into instance variables.
Name | Type | Description |
---|---|---|
$schemeSpecific | string | The scheme-specific portion to parse |
Exception | Description |
---|---|
\Zend_Uri_Exception | When scheme-specific decoposition fails |
\Zend_Uri_Exception | When authority decomposition fails |
addReplaceQueryParameters(array $queryParams) : string
Add or replace params in the query string for the current URI, and return the old query.
Name | Type | Description |
---|---|---|
$queryParams | array |
Type | Description |
---|---|
string | Old query string |
fromString(string $uri) : \Zend_Uri_Http
Creates a Zend_Uri_Http from the given string
Name | Type | Description |
---|---|---|
$uri | string | String to create URI from, must start with
|
Type | Description |
---|---|
\Zend_Uri_Http |
Exception | Description |
---|---|
\InvalidArgumentException | When the given $uri is not a string or does not start with http:// or https:// |
\Zend_Uri_Exception | When the given $uri is invalid |
getFragment() : string | false
Returns the fragment portion of the URL (after #), or FALSE if none.
Type | Description |
---|---|
string | false |
getHost() : string
Returns the domain or host IP portion of the URL, or FALSE if none.
Type | Description |
---|---|
string |
getPassword() : string
Returns the password portion of the URL, or FALSE if none.
Type | Description |
---|---|
string |
getQuery() : string
Returns the query portion of the URL (after ?), or FALSE if none.
Type | Description |
---|---|
string |
getQueryAsArray() : array
Returns the query portion of the URL (after ?) as a key-value-array. If the query is empty an empty array is returned
Type | Description |
---|---|
array |
getUri() : string
Returns a URI based on current values of the instance variables. If any part of the URI does not pass validation, then an exception is thrown.
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When one or more parts of the URI are invalid |
getUsername() : string
Returns the username portion of the URL, or FALSE if none.
Type | Description |
---|---|
string |
removeQueryParameters(array $queryParamKeys) : string
Remove params in the query string for the current URI, and return the old query.
Name | Type | Description |
---|---|---|
$queryParamKeys | array |
Type | Description |
---|---|
string | Old query string |
setFragment(string $fragment) : string
Sets the fragment for the current URI, and returns the old fragment
Name | Type | Description |
---|---|---|
$fragment | string | Fragment of the current URI |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $fragment is not a valid HTTP fragment |
setHost(string $host) : string
Sets the host for the current URI, and returns the old host
Name | Type | Description |
---|---|---|
$host | string | The HTTP host |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $host is nota valid HTTP host |
setPassword(string $password) : string
Sets the password for the current URI, and returns the old password
Name | Type | Description |
---|---|---|
$password | string | The HTTP password |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $password is not a valid HTTP password |
setPath(string $path) : string
Sets the path for the current URI, and returns the old path
Name | Type | Description |
---|---|---|
$path | string | The HTTP path |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $path is not a valid HTTP path |
setPort(string $port) : string
Sets the port for the current URI, and returns the old port
Name | Type | Description |
---|---|---|
$port | string | The HTTP port |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $port is not a valid HTTP port |
setQuery(string | array $query) : string
Set the query string for the current URI, and return the old query string This method accepts both strings and arrays.
Name | Type | Description |
---|---|---|
$query | string | array | The query string or array |
Type | Description |
---|---|
string | Old query string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $query is not a valid query string |
setUsername(string $username) : string
Sets the username for the current URI, and returns the old username
Name | Type | Description |
---|---|---|
$username | string | The HTTP username |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Uri_Exception | When $username is not a valid HTTP username |
valid() : boolean
Validate the current URI from the instance variables. Returns true if and only if all parts pass validation.
Type | Description |
---|---|
boolean |
validateFragment(string $fragment = null) : boolean
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.
Name | Type | Description |
---|---|---|
$fragment | string | Fragment of an URI |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When fragment validation fails |
validateHost(string $host = null) : boolean
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.
validatePassword(string $password = null) : boolean
Returns true if and only if the password passes validation. If no password is passed, then the password contained in the instance variable is used.
Name | Type | Description |
---|---|---|
$password | string | The HTTP password |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When password validation fails |
validatePath(string $path = null) : boolean
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.
Name | Type | Description |
---|---|---|
$path | string | The HTTP path |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When path validation fails |
validatePort(string $port = null) : boolean
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.
Name | Type | Description |
---|---|---|
$port | string | The HTTP port |
Type | Description |
---|---|
boolean |
validateQuery(string $query = null) : boolean
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.
Name | Type | Description |
---|---|---|
$query | string | The query to validate |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When query validation fails |
validateUsername(string $username = null) : boolean
Returns true if and only if the username passes validation. If no username is passed, then the username contained in the instance variable is used.
Name | Type | Description |
---|---|---|
$username | string | The HTTP username |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Uri_Exception | When username validation fails |