Lamar
Lamar

Reputation: 1849

Get path of parent file from included file in php, I don't need the folder path but the full path of including page

I have a php file that could be included in different places. I need to have some rule on what to show depending on the including file.

Using $_SERVER['REQUEST_URI'] is returning the path of the page itself not the parent file that's including it.

Upvotes: 1

Views: 1366

Answers (1)

Maltronic
Maltronic

Reputation: 1802

Try:

<?php
echo $_SERVER['SCRIPT_FILENAME'];

The full list can be found on the PHP website.

Upvotes: 3

Related Questions