<?
class custUrl {
var $keys = array();
var $base = '';
function custUrl($base='') {
$this->base = $base;
}
function setKey($name='',$val='') {
if ($name) {
$this->keys[$name] = $val;
}
}
function dropKey($name='') {
if ($name) {
unset($this->keys[$name]);
}
}
function setBase($val) {
$this->base = $val;
}
function getKey($name) {
return $this->keys[$name];
}
function asString() {
$res = $this->base;
if (count($this->keys)>0) $res .= '?';
$tarr = array();
foreach ($this->keys as $key=>$val) {
$tarr[] = $key.'='.(urlencode($val));
}
$res .= implode('&',$tarr);
return $res;
}
function asHtml($name='') {
$res = "<a href=\"".$this->asString()."\">$name</a>";
return $res;
}
}
?> |