I can\'t believe PHP doesn\'t have an easy solution for this simple matter. ASP.NET has a ~ sign that takes care of this issue and starts everything from the root level. Her
The best way Using dirname(). Because SERVER['DOCUMENT_ROOT'] not working all servers, and also return server running path.
$root = dirname( __FILE__ );
$root = __DIR__;
$filePath = realpath(dirname(__FILE__));
$rootPath = realpath($_SERVER['DOCUMENT_ROOT']);
$htmlPath = str_replace($root, '', $filePath);