Do you want to know how to retrieve WordPress root directory path the correct way?
You will find many solutions for this question on internet but most of the solutions an extra effort and will decrease you website efficiency maybe by .00001 sec but why even waste that? WordPress has most of the thing built in to help you customise it the way you want.
If you have a look at the
wp-config.php file and search for the code below, you will find that WordPress already have the root path assigned to a global variable.
if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/');
Now if you you
echo ABSPATH;, you will get root path echoed.
Feel free to comment below if you have some suggestions and queries.