WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP5 URL Object
Categories : PHP, PHP Classes, URLs, Strings Click here to Update Your Picture
Joseph Crawford
Date : Dec 07th 2005
Grade : 2 of 5 (graded 3 times)
Viewed : 8261
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Joseph Crawford
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

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 '';
  }
}

?>



Filter - A simple class that lets you use multiple functions to create custom filters.
Categories : PHP, PHP Classes, Strings
Class to Create protected URLs
Categories : PHP, PHP Classes, URLs
SubmitForce URL power submitter (searchengine submission class)
Categories : PHP, Search Engines, URLs, PHP Classes
Class TStringList include some metods from class TStringList implemented in INPRISE/BORLAND-DELPHI
Categories : PHP Classes, PHP, Strings
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
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
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
Compare two texts and display a block of text with the differences between them.
Categories : PHP, PHP Classes, Filesystem, Strings, Arrays
Password reminder
Categories : PHP, PHP Classes, Databases, MySQL, Mail
Form Elements Class
Categories : PHP, PHP Classes, Form Processing
Produces browser-safe strings while preserving HTML tags.
Categories : Strings, HTTP, PHP, HTML and PHP
DbObject - A PHP wrapper for working with various databases
Categories : Databases, PHP, PHP Classes
The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view.
Categories : PHP, PHP Classes, Java Script, AJAX, Databases
Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs