path.php

  View Code

Click on the links in the menu for more PHP examples.

Server Path and Directory Information

- file name, path, server details

A file path describes the location of a file in a web site's folder structure.

Here are some examples of PHP. This page uses the php code,
basename($_SERVER['PHP_SELF']); which Returns The Current PHP page Name.
The current page name is: path.php


To get your current working directory use: getcwd()
The working directory is: /home/u346389993/domains/d4datasystems.com/public_html/my-php

To get the document root directory: $_SERVER['DOCUMENT_ROOT']
the document root directory is: /home/u346389993/domains/d4datasystems.com/public_html

To get the filename of the current script: $_SERVER['SCRIPT_FILENAME']
The filename of the current script is: /home/u346389993/domains/d4datasystems.com/public_html/my-php/path.php

Use this php code, realpath('path.php') but insert your current page name in the parentheses to echo the real path.
The real path is: /home/u346389993/domains/d4datasystems.com/public_html/my-php/index.php

As you can see there are several ways to return the current file name, directory and path information.