Posted inProgramming / php

How to Get Absolute Directory Path in PHP Script

Today, We want to share with you How to Get Absolute Directory Path in PHP Script.In this post we will show you php get directory of current file, hear for How to get absolute path on a web server using PHP we will give you demo and example for implement.In this post, we will learn about How to get the absolute path to the public_html folder with an example.

How to Get Absolute Directory Path in PHP Script

There are the Following The simple About How to Get Absolute Directory Path in PHP Script Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to get selected file path in php, so the php get root directory of website for this example is following below.

Example 1:

using dirname(__FILE__)


Example 2:

using new constant called __DIR__


Example 3:

absolute directory path in PHP


Bonus

echo realpath(dirname(__FILE__));

//other way
echo getcwd();

//new 
print_r($_SERVER['DOCUMENT_ROOT']);


// absolute path with file name
echo $_SERVER['SCRIPT_FILENAME'];
Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about How to Get Absolute Directory Path in PHP Script.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype