Advanced Search

Results 1 to 2 of 2

Thread: How to get Filename

  1. #1
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default How to get Filename

    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:
    Code:
    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
    Code:
    ...
    include "home.php";
    ...
    home.php
    Code:
    ...
    <?php
    //get "home.php" some how
    ?>
    ...
    And the page is being parsed from "index.php".
    - Mike

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Nevermind, just figured out how to do it. Just this:
    Code:
    <?php
    echo basename(__FILE__);
    ?>
    - Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •