In order to get the root directory path, you can use _DIR_ or dirname().
The syntax is as follows −
echo _DIR_;
The second syntax is as follows−
echo dirname(__FILE__);
Both the above syntaxes will return the same result.
Example
<!DOCTYPE html> <html> <body> <?php echo dirname(__FILE__); echo "<br>"; echo __DIR__; ?> </body> </html>
Output
/home/KOq8Zd /home/KOq8Zd