ar\url
This module allows you to easily create and modify URL's. e.g.
<pinp>
$url = ar::url( 'http://www.ariadne-cms.org/' );
$url->path = '/docs/search/';
$url->query->searchstring = 'test';
echo $url;
</pinp>
This code echoes the following url:
http://www.ariadne-cms.org/docs/search/?searchstring=test
You can change any of the following components:
scheme |
e.g. 'http ' | |
user |
A user name to include in the url. | |
password |
A password to include in the url, will only be included if a username is also specified. | |
host |
The host name, e.g. 'www.ariadne-cms.org '. | |
port |
The port number. | |
path |
The path. | |
query |
The query string. This is also automatically parsed to an object and you can access any variable inside it as a normal php variable. See the example above. You can also use it as an array, it extends ArrayObject. | |
fragment |
The html fragment after the '#'. |
When parsing a URL the query arguments are automatically tainted if tainting is enabled in ar\http.
methods
(mixed) |
getvar |
Returns the named argument from the query part. |
(void) |
import |
Imports a list of name => value pairs into the query. |
(void) |
putvar |
Inserts a new named argument into the query. |
These methods can be called on the URL directly or on the query part, there is no difference.
getvar
(mixed) $url->getvar( $name )
(mixed) $urlQuery->getvar( $name )
(string) |
name |
The name of the argument to retrieve |
Returns the named argument from the query part of the URL.
import
(void) $url->import( $values )
(void) $urlQuery->import( $values)
(mixed) |
$values |
A list of name => value pairs to import into the query part of the URL. Can be either an array or a URL encoded string. |
Imports each name => value pair into the query part of the URL. e.g.
<pinp>
$url = ar::url( 'http://ariadne-cms.org/' );
$url->import( array( 'key1' => 'a value', 'key2' => 'value 2' ) );
echo $url;
</pinp>
Results in:
http://ariadne-cms.org/?key1=a%20value&key2=value%202
putvar
(void) $url->putvar( $name, $value )
(void) $urlQuery->putvar( $name, $value )
(string) |
$name |
The name ot the argument to set. |
(mixed) |
$value |
The value for the argument. |
Updates or inserts a named argument in the URL query.