derrida
asked on
path issue
Hi
i have a database class that require_once a config file like so: require_once 'configs/configs.php';
all works until i require that class from a vertain folder, then the require inside the class doesn't work and i get:
<b>Warning</b>: require_once(configs/confi gs.php): failed to open stream: No such file or directory
any idea?
i have a database class that require_once a config file like so: require_once 'configs/configs.php';
all works until i require that class from a vertain folder, then the require inside the class doesn't work and i get:
<b>Warning</b>: require_once(configs/confi
any idea?
ASKER
still get the same result.
i need that whereever i call the databse class the configs will work. now it work from some places and doesn't work on others.
i need that whereever i call the databse class the configs will work. now it work from some places and doesn't work on others.
If you want it to work from wherever you call it then you will need to use an absolute path, and not a relative one. a relative path is always 'relative' the the script you're calling from. An absolute path is the same, no matter where you call it from.
ASKER
that's what i'm trying to do now and fail. how do i set an absolute path to the configs file in the database class? i have played with realpath but doesn't work.
i have a classes folder and the class is in there. i have a configs folder and the configs file is there. both the classes and the configs folders are in the root folder.
i have a classes folder and the class is in there. i have a configs folder and the configs file is there. both the classes and the configs folders are in the root folder.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
saved my life thanks :)
Add a leading slash and you'll get an absolute path, always starting at the root. You probably need to add the leading slash:
require_once(/configs/conf
This will always load it from the /configs folder.