fURLstatic classv1.0.0b5
Provides functionality to retrieve and manipulate URL information
This class uses $_SERVER['REQUEST_URI'] for all operations, meaning that the original URL entered by the user will be used, or that any rewrites will not be reflected by this class.
| 1.0.0b5 | Updated redirect() to not require a URL, using the current URL as the default 7/29/09 |
|---|---|
| 1.0.0b4 | getDomain() now includes the port number if non-standard 5/2/09 |
| 1.0.0b3 | makeFriendly() now changes _-_ to - and multiple _ to a single _ 3/24/09 |
| 1.0.0b2 | Fixed makeFriendly() so that _ doesn't appear at the beginning of URLs 3/22/09 |
| 1.0.0b | The initial implementation 6/14/07 |
Static Methods
::get() public
Returns the requested URL, does no include the domain name or query string
This will return the original URL requested by the user - ignores all rewrites.
Signature
string get( )
Returns
The requested URL without the query string
::getDomain() public
Returns the current domain name, with protcol prefix. Port will be included if not 80 for HTTP or 443 for HTTPS.
Signature
string getDomain( )
Returns
The current domain name, prefixed by http:// or https://
::getQueryString() public
Returns the current query string, does not include parameters added by rewrites
Signature
string getQueryString( )
Returns
The query string
::getWithQueryString() public
Returns the current URL including query string, but without domain name - does not include query string parameters from rewrites
Signature
string getWithQueryString( )
Returns
The URL with query string
::makeFriendly() public
Changes a string into a URL-friendly string
Signature
void makeFriendly( string $string )
Parameters
| string | $string | The string to convert |
::redirect() public
Redirects to the URL specified, without requiring a full-qualified URL
- If the URL starts with /, it is treated as an absolute path on the current site
- If the URL starts with http:// or https://, it is treated as a fully-qualified URL
- If the URL starts with anything else, including a ?, it is appended to the current URL
- If the URL is ommitted, it is treated as the current URL
Signature
void redirect( string $url=NULL )
Parameters
| string | $url | The url to redirect to |
::removeFromQueryString() public
Removes one or more parameters from the query string
This method uses the query string from the original URL and will not contain any parameters that are from rewrites.
Signature
string removeFromQueryString( string $parameter )
Parameters
| string | $parameter [, ... ] | A parameter to remove from the query string |
Returns
The query string with the parameter(s) specified removed, first character is ?
::replaceInQueryString() public
Replaces a value in the query string
This method uses the query string from the original URL and will not contain any parameters that are from rewrites.
Signature
string replaceInQueryString( string|array $parameter, string|array $value )
Parameters
| string|array | $parameter | The query string parameter |
| string|array | $value | The value to set the parameter to |
Returns
The full query string with the parameter replaced, first char is ?
