Like this code?
Show the author your appreciation.
I also thought i would post my URL class, this is a basic class that takes advantage of the parse_url php function and implements the __toString method so you can do echo $url;
$url->GetLink('Link Title', 'Custom Target - _blank, _top', 'Custom CSS Class');
class URL extends Object {
private $protocol;
private $user;
private $pass;
private $hostname;
private $port;
private $path;
public function __construct($url = '') {
if($url == '') throw new URLEx('Cannot create a URL object without specifying a string.');
$data = parse_url($url);
$this->protocol = $data['scheme'];
if(isset($data['user'])) $this->user = $data['user'];
if(isset($data['pass'])) $this->pass = $data['pass'];
if(isset($data['host'])) $this->hostname = $data['host'];
if(isset($data['port'])) $this->port = $data['port'];
if(isset($data['path'])) $this->path = $data['path'];
if(isset($data['query'])) $this->query = $data['query'];
}
public function __toString() {
$url = $this->protocol.'://';
if(isset($this->user) && isset($this->pass)) $url .= $this->user .':'. $this->pass.'@';
$url .= $this->hostname;
if(isset($this->port)) $url .= ':'.$this->port;
if(isset($this->path)) $url .= $this->path;
if(isset($this->query)) $url .= '?'.$this->query;
return $url;
}
public function GetLink($title = null, $target = '_blank', $class='link') {
$url = $this->protocol.'://';
if(isset($this->user) && isset($this->pass)) $url .= $this->user .':'. $this->pass.'@';
$url .= $this->hostname;
if(isset($this->port)) $url .= ':'.$this->port;
if(isset($this->path)) $url .= $this->path;
if(isset($this->query)) $url .= '?'.$this->query;
if(is_null($title)) $title = $url;
return '<a href="'.$url.'" target="'.$target.'" class="'.$class.'">'.$title.'</a>';
}
public function GetProtocol() {
if(isset($this->protocol)) return $this->protocol;
else return '';
}
public function GetUser() {
if(isset($this->user)) return $this->user;
else return '';
}
public function GetPass() {
if(isset($this->pass)) return $this->pass;
else return '';
}
public function GetHostname() {
if(isset($this->hostname)) return $this->hostname;
else return '';
}
public function GetPort() {
if(isset($this->port)) return $this->port;
else return '';
}
public function GetPath() {
if(isset($this->path)) return $this->path;
else return '';
}
}
?>
SubmitForce URL power submitter (searchengine submission class) Categories : PHP , Search Engines , URLs , PHP Classes Gonx URLs - This class is meant to generate URLs for accessing application dynamically generated pages based on parameters passed in the URL.
Categories : PHP , PHP Classes , Navigation , URLs Filter - A simple class that lets you use multiple functions to create custom filters. Categories : PHP , PHP Classes , Strings Compare two texts and display a block of text with the differences between them. Categories : PHP , PHP Classes , Filesystem , Strings , Arrays Class TStringList include some metods from class TStringList
implemented in INPRISE/BORLAND-DELPHI Categories : PHP Classes , PHP , Strings Class to Create protected URLs Categories : PHP , PHP Classes , URLs pick up an array of variables from a query string such as:
http://www.archipro.com/test.php?state=AB&state=BC
Categories : PHP , Strings , URLs , Global Variables STR - a Perl-like string manipulator class - The str class provides 4 perl-like methods for manipulating strings and
other scalar variables. Categories : PHP , PHP Classes , Perl , Strings Remove URL Parameter Substr Strstr Categories : PHP , URLs , Strings Link Manager for Link Exchangers Categories : PHP , PHP Classes , Databases , MySQL , CURL Search and Replace Text : Searches Files for Specified Text and Replaces It by a Given Text Categories : PHP , PHP Classes , Search , Filesystem columned txt file to array()? Categories : Arrays , Strings , Regexps , PHP Timer - a class that uses microtime() to provide easy calculation of elapsed times Categories : Algorithms , PHP , PHP Classes Class to convert any document, that can be read by MS Word, to another format supported by Word. Categories : PHP Classes , PHP , Windows 2000 , Microsoft Word , WinNT Sort the results from a SELECT query (any number of columns) into an array automatically. Categories : PHP , PHP Classes , Arrays , Databases , MySQL