I'm having some issues with defined absolute paths in PHP. I define the SITE_ROOT
and APP_PATH
like so:
defined('SITE_ROOT') ? null :
define('SITE_ROOT', str_replace('//','/',dirname(__FILE__)) );
defined('APP_PATH') ? null : define('APP_PATH', SITE_ROOT.DS.'application');
When using the APP_PATH
in an application like so:
echo APP_PATH;
...this is what I get:
/Users/user/Sites/MyWebsite/application
What I want is for the output to be:
localhost/application
Is there any non-kludgy way of doing this?
My use case is to use the APP_PATH
(already in use for doing all my require()
's) echoed out with HTML to avoid relative pathing problems within URLs for href
's.