URL - introduction

Welcome! This is a URL helper class, that simplifies the tasks of handling urls. The class can either be used as a static class but it can be instantiated too.

Static method

Basic usage
URL::get()
get the current url
URL::add('x',1)
add argument x=1
URL::add(Array('x'=>1,'y'=>2)) 1,'y'=>2)); ?>
add arguments x=1, y=2
URL::add(Array('x'=>Array('a'=>1, 'b'=>'foo'))) Array('a'=>1, 'b'=>'foo'))) ?>
add array as paramter
URL::path('path/to/stuff')
set path as string
URL::path(Array('path','to','stuff'))
set path as array
URL::path('path','to','stuff')
set path with arguments
URL::file('path','to','stuff.txt')
set file with arguments
URL::canonical()
get the canonical link for current url
URL::args()
get the arguments
URL::args(Array('x'=>1,'y'=>2)) 1,'y'=>2)); ?>
set the arguments (same syntax as at URL::add)
URL::hash('test')
set hash
Passing base
$url = URL::file('path','to','file.html')
set file
$url = URL::add(Array('x'=>1,'y'=>2),false,$url) 1,'y'=>2),false,$url); ?>
add arguments x=1, y=2, store results in $url
$url = URL::add('z',3,$url)
add z = 3 to previously stored $url
$url = URL::remove('y',$url)
remove y from previously stored $url
URL::args(false, false, $url)
get the arguments from $url
URL::hash('test',$url)
set hash for $url
(note: the hash does not get stored in the $url)
URL::canonical($url)
get the canonical link for $url
URL::canonical($url, true)
get the canonical link for $url w/ args

Instance method

$url = new URL() -
create url object
echo $url
print url
$url->add('x',1) add('x',1) ?>
add x=1
$url->add(Array('y'=>'stuff','z'=>3)) add(Array('y'=>'stuff','z'=>3)) ?>
add y=stuff & z=3
$url->add(Array('x'=>Array('a'=>1, 'b'=>'foo'))) add(Array('x'=>Array('a'=>1, 'b'=>'foo'))) ?>
add array as paramter
$url->args() args()) ?>
get args
$url->remove('z') remove('z') ?>
remove z
$url->remove() remove() ?>
remove all args
$url->path('path','to','stuff') path('path','to','stuff') ?>
set path
$url->file('path','to','stuff.html') file('path','to','stuff.html') ?>
set file path
$url->basepath('base/folder') basepath('base/folder') ?>
set base path
$url->hash('test') hash('test'); ?>
set hash
$url->canonical() canonical(); ?>
canonical link

The functions are the same for the two styles. For further info, check the documentation in the source, or generate the doc with Doxygen.