lets say we have a directory.
project/index.php
in index.php
<?php
require 'config/config.php';
echo ROOTPATH;
?>
project/config/config.php
<?php
define('ROOTPATH', rtrim(dirname(__FILE__), '\\/'));
?>
it will return like
D:\Project Storage\Web Projects\www\project\config.
question:
-
is there an easy way to get the rootpath without puting it on the project folder ? ( i know this is supid but i cant stand to ask )
-
is there a way to get the \project\ ( root folder ) ? even if we change the folder location ?
Thanks
Adam Ramadhan
ps*
please leave a comment if you dont understand what i mean.
realpath()ITs your friend.. for example:in config/config.php
Or to get the folder above project:
I dont work on windows, but if i recall
realapathwill sort out the slashes for you… if thats not the case then use theDIRECTORY_SEPARATORconstant for compatibility.