$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/...