Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Get Root Directory Path of a PHP project?
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
Advertisements
