joaofigueiras Posted January 12, 2010 Share Posted January 12, 2010 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? Link to comment https://forums.phpfreaks.com/topic/188259-path-of-the-file-inside-a-subdirectory-that-is-called-by-an-include/ Share on other sites More sharing options...
mikesta707 Posted January 12, 2010 Share Posted January 12, 2010 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 Link to comment https://forums.phpfreaks.com/topic/188259-path-of-the-file-inside-a-subdirectory-that-is-called-by-an-include/#findComment-993874 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.