Log in

View Full Version : Resolved How to get Filename



mburt
09-26-2011, 11:31 PM
So I've got a file which includes another file, and from that file I want to be able to write the included file's file name. I've been looking this up for a while, but I can't seem to find it.

Simply using:

basename($_SERVER["PHP_SELF"])
won't do because that will only return the parent file's file name (I know, this might seem a little bit useless, but I need it for a template system I'm working on). Wondering if anyone out there knows how to do this.

The structure is like this:

index.php

...
include "home.php";
...

home.php

...
<?php
//get "home.php" some how
?>
...
And the page is being parsed from "index.php".

mburt
09-26-2011, 11:34 PM
Nevermind, just figured out how to do it. Just this:

<?php
echo basename(__FILE__);
?>