<<< Coding for the future >>>
| Current page url |
|
|
|
| Tuesday, 24 November 2009 15:51 |
|
Getting the current page URL can be dependend on the server set up. The standard function (which may not always work! - read on if your stuck!) goes like this:
function curPageURL() {
It looks pretty but does not always return the full URL especially if you have a lot of pass variables in the url. The $_SERVER array contains a lot of useful information. You can see what it holds by printing it out:
print_r($_SERVER); If you search for your string of variables in the printed out array, you'll probably find them under QUERY_STRING, i.e. $_SERVER['QUERY_STRING'] To get the full url then, you're pageurl in the function we begun with might look something like this: $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
Simply replace the $pageurl variables in the function above with this line! Note, I haven't allowed for https, or non-standard ports. You'll have to substitute in those into your pageurl variable from the function.
|
| Last Updated on Tuesday, 24 November 2009 16:07 |