How to get current file path in PHP

How to get and show current file location in php,linux server web hosting with folder structure.

Current file whole path including folder structure at the beginning to end can be detect through $_SERVER[‘SCRIPT_FILENAME’] method. This method will return the whole file currently running php script file path so developer can perform various task on them as their requirement. So here is the complete step by step tutorial for How to get current file path in PHP.

android-project-download-code-button

How to get current file path in PHP.

Code for current-file-path.php file.

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Get current file path in PHP</title>
</head>

<body>

<?php 
$filepath = $_SERVER['SCRIPT_FILENAME'];
echo $filepath;
?>

</body>
</html>

Screenshot:

How to get current file path in PHP

Click here to download How to get current file path in PHP project with source code in php.

Leave a Reply

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