To this day i'm using that piece of code to locate public_html to count the folders to go back in order to import files:
$config_path = array_reverse(explode( DIRECTORY_SEPARATOR , getcwd()));
$co = 0;
foreach($config_path as $val){
if($val == "public_html")
break;
$co += 1;
}
$config_path = '';
if($co != 0){
for($i = 0 ; $i < $co ; $i++){
$config_path .= '../';
}
}
and then i'm using it like that:
require_once ($config_path.'core/db-class.php');
That piece of code serve me pretty good , though I feel like its limiting me because when I use WAMP I need to have public_html folder and such
I'm looking for a php function something like - getMainRoot()
So I can do something like
require_once (getMainRoot().'core/db-class.php');