Visit this project's SourceForge Project Page
Main Page | Class List | Directories | File List | Class Members | File Members | Related Pages

EUrl: The Easy URL Generator

HOWTO use EUrl

The most important thing to know is that there is one magic function you want. EUrl::Generate(). Here are the two ways you can use it:

 $url = EUrl::Generate();

 $MyEurl = new EUrl();
 $url = $MyEurl->Generate();

Both versions go through the same list of possible inputs for creating the URL, with the exception of the statically-called version not checking instantiated variables (as that call method is non-instantiated).

To build the URL, the Generate() function goes through (what has become) a large list of data sources. The first data source that it finds with a value which is NOT NULL, it will use and ignore all others.

Scope list (traverses from first to last, first wins): Skip to the ordered list of data sources

In short, it searches for your input first, and then spirals outward to find anything from the environment that it can. This gives you LOTS of options for usage. One of my personal favorites is setting up mod_rewrite rules in apache, and assigning an environment variable to make output URLs match the rewrite rule. This is a very powerful tool for those obsessed with Search Engine Optimization. Here is an example rewrite rule:

 RewriteEngine On
 RewriteRule ^/~user$      /~user/HelloWorld.php    [PT]
 RewriteRule ^/~user/(.*)$ /~user/HelloWorld.php/$1 [PT]
 <Files HelloWorld.php>
     SetEnv EURL_VAR_INDEX_PATH /~user
 </Files>

 

Now if you visit yoursite.com/~user, you'll get the HelloWorld.php file, and yet all the links generated from within the HelloWorld.php file will appear to be linking directly to yoursite.com/~user/...

Definition of internal variables used to make a URL:

Scope list (traverses from first to last, first wins):

User settable constants (all are optional):

User settable environment variables (all are optional):




Generously hosted by   SourceForge.net Logo
Generated on Wed Jun 1 11:01:06 2005 for EUrl by   Doxygen 1.4.1