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
get the current url
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
set path as string
set path as array
set path with arguments
set file with arguments
get the canonical link for current url
get the arguments
URL::args(Array('x'=>1,'y'=>2)) 1,'y'=>2)); ?>
set the arguments (same syntax as at URL::add)
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
set hash for $url
(note: the hash does not get stored in the $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.