Login   Register  
PHP Classes
elePHPant
Icontem

File: urllib.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Eugene Panin  >  Custom URL  >  urllib.php  >  Download  
File: urllib.php
Role: ???
Content type: text/plain
Description: Class library
Class: Custom URL
Author: By
Last change:
Date: 2001-04-20 10:50
Size: 1,197 bytes
 

Contents

Class file image Download
<?
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;
        }
}
?>