Absolute path is the complete path of a file, also termed as physical path. In this tutorial, we will use php absolute path function to find the complete path of any file.
Step 1 – Use real path function
In php, absolute paths can be found with the help of an implicit php function called real path. This function will take the path of the directory in its argument and will return the complete physical path.
For the purpose of this article, we have given a system 32 folder, located inside the windows directory, in the argument of php absolute path function and we will simply print the output using the “Echo” function.
Step 2 – Specify the Location
Once you are done with the code, save the file as PHP extension in the root directory of the hosting server that is being used. Since, we are using Apache with Wampp Server, our project directory is “www”.
Step 3 – View the Path
Once the file has been saved, open up the browser. In the search bar, enter the local host along with the port number followed by the name of the file that you just created.
You will notice that the complete path of the system 32 folder is displayed on the screen as a result.
In this manner, we can find php absolute paths.