开发者

Path constant in PHP

开发者 https://www.devze.com 2023-03-02 22:26 出处:网络
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

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__)));
0

精彩评论

暂无评论...
验证码 换一张
取 消