Jump to content

Path of the file, inside a subdirectory, that is called by an include


joaofigueiras

Recommended Posts

Hello all,

 

I have the following directory structure from root:

./

./Subdir/

 

Inside "./Subdir/", I have the file "file_subdir.php" with code:

<?php
echo $_SERVER['PHP_SELF'];
?>

 

Inside "./", I have the file "file_root.php" with code:

<?php
include('./Subdir/file_subdir');
?>

 

If I run "file_subdir.php", I get the output:

./Subdir/file_subdir.php

 

And if I run "file_root.php", I get the output:

./file_root.php

 

What I want is the output of file "file_root.php" to be the path of the file pointed by the include (since the code is inside that include), i.e., I want the output of "file_root.php" to be:

./Subdir/file_subdir.php

 

How can I do it?

A list of all server variables: http://www.php.net/manual/en/reserved.variables.server.php

 

have you tried using $_SERVER['SCRIPT_FILENAME'];?

 

check out that manual page and see if one of those will work

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.