Skip to content
PHP Logo

What is the best method to display the current path of a document using PHP?

To display the current path of a document in PHP, you can use the $_SERVER['REQUEST_URI'] variable. This variable contains the URL path of the current request. You can then echo this variable to display the current path to the user.

php
$currentPath = $_SERVER['REQUEST_URI'];
echo "Current Path: " . $currentPath;