Flourish PHP Unframework

fURL

static class, v1.0.0b10

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.

Changes:
1.0.0b10Fixed some method signatures 8/24/11
1.0.0b9Fixed redirect() to handle no parameters properly 6/13/11
1.0.0b8Added the $delimiter parameter to makeFriendly() 6/3/11
1.0.0b7Fixed redirect() to be able to handle unqualified and relative paths 3/2/11
1.0.0b6Added the $max_length parameter to makeFriendly() 9/19/10
1.0.0b5Updated redirect() to not require a URL, using the current URL as the default 7/29/09
1.0.0b4getDomain() now includes the port number if non-standard 5/2/09
1.0.0b3makeFriendly() now changes _-_ to - and multiple _ to a single _ 3/24/09
1.0.0b2Fixed makeFriendly() so that _ doesn't appear at the beginning of URLs 3/22/09
1.0.0bThe 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

Signatures

string makeFriendly( string $string, integer $max_length=NULL, string $delimiter=NULL )

string makeFriendly( string $string, string $delimiter=NULL )

Parameters

string $string The string to convert
integer $max_length The maximum length of the friendly URL
string $delimiter The delimiter to use between words, defaults to _

Returns

The URL-friendly version of the string

::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 ?