
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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