Jump to content

A better way of getting various data from URL?


MrSean

Recommended Posts

Sample URL:

http://localhost/cms/page/home/

 

The script is in:

/www/cms/

 

ROOT should be where the script is installed.

URL should be the rest of the url (ignoring query string)

 

This is what I have:

define('ROOT', (dirname(__FILE__)));
$URL = str_replace(realpath($_SERVER['DOCUMENT_ROOT']).'/', '', realpath(dirname(__FILE__))).'/';
define('URL', str_replace('/'.$URL, '', $_SERVER['REQUEST_URI']));

echo "ROOT:".ROOT . "<br />";
echo "URL:".URL . "<br />";

 

So, is there a cleaner way f doing this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.