I'm trying to learn a better way to go back to the root directory. I heard that using $_SERVER isn't the safest way. Im wondering if there is a better way. so i could get something like this on the url example.com/exp/my.php
here's what i got.
include ($_SERVER['DOCUMENT_ROOT'].'/cpages/cmain/func/init.php');
include($_SERVER['DOCUMENT_ROOT'].'/cpages/toppart.php');
include($_SERVER['DOCUMENT_ROOT'].'/cpages/boxes/image.php');
include($_SERVER['DOCUMENT_ROOT'].'/cpages/bottonpart.php');
I change it to
define ('DOCUMENT_ROOT', dirname(__FILE__));
include (DOCUMENT_ROOT.'/cpages/cmain/func/init.php');
include(DOCUMENT_ROOT.'/cpages/toppart.php');
include(DOCUMENT_ROOT.'/cpages/boxes/image.php');
include(DOCUMENT_ROOT.'/cpages/bottonpart.php');
but now it's giving me a error
Warning: include(C:\xampp\htdocs\backbone\image/cpages/cmain/func/init.php)
and ($_SERVER['DOCUMENT_ROOT']
didn't gave it me that error is their a way to fix it ?