Path constant in PHP
I have different classes and a configuration file in my PHP Application. The classes sits inside a single directory. My application structure is as follows
/ApplicationName
/administrator
adminFiles.php
someMoreAdmingFiles.php
anotherAdminFiles.php
/resources
/config
config.php
/library
开发者_如何转开发 /class
class.user.php
class.acl.php
/models
/logs
/templates
/contents
/uploads
/css
/img
/css
i would like to create path CONSTANTS in config.php, now i used the following code to create a path constant for class.user.php
define('USERCLASS_PATH',$_SERVER['DOCUMENT_ROOT'].'/ApplicationName/administrator/resources/library/class/class.user.php');
Above CONSTANT generates the following string.
/Applications/MAMP/htdocs/ApplicationName/administrator/resources/library/class/class.user.php
is there any better way for achieving this?
I usually use something in the lines of:
define("PATH_ROOT", realpath(dirname(__FILE__)));
精彩评论