Results 1 to 17 of 17

Thread: retrieve filename

  1. #1

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609

    retrieve filename

    how can i retrieve the filename of the current file and get a result like "index.php" ?????

  2. #2

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    the ASP equivalent would be
    Code:
    <%
    Request.Servervariables("path_info")
    %>
    but would return a value something like: "dir/filename.ASP" ; that would do for what i want, anything like that but in PHP please ??

    any help appreciated greatly.



    _Ubunr3al_

  3. #3
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    PHP Code:
    print $PHP_SELF

  4. #4

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    thanx chrisjk, i'll give it a try. u wouldnt happen top know how to do include scripts in php woud ya ?

  5. #5
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    yep, you can include other php scripts like this
    PHP Code:
    require('./other.php3'); 
    that could include functions and whatnot.

  6. #6
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    As a side note, use require if it must work, e.g. the file must exist, otherwise use include. If you use include (same syntax) then the script will continue even if there are problems

  7. #7

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    ok, so they work exacly the same except one displays errors if there is any ?

  8. #8
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    that is correct

  9. #9
    scoutt
    Guest
    Originally posted by ubunreal69
    ok, so they work exacly the same except one displays errors if there is any ?
    uhhhhh no, they don't have anything to do with errors.


    include() differs from require() in that the include statement is re-evaluated each time it is encountered (and only when it is being executed), whereas the require() statement is replaced by the required file when it is first encountered, whether the contents of the file will be evaluated or not (for example, if it is inside an if statement whose condition evaluated to false).

  10. #10
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    don't be so hasty scoutt...

    from php.net

    The two constructs are identical in every way except how they handle failure....use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless.
    Last edited by chrisjk; Feb 25th, 2002 at 04:47 PM.

  11. #11

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    Originally posted by chrisjk
    don't be so hasty scoutt...

    lol this could get funny

  12. #12
    scoutt
    Guest
    well was that in the manual? maybe I didn't read down far enough. but I could swear that when I include it does stop on errors. but my fading brain my say different. I go tmy quote from the manual, but like I said I must not have read far enough.

  13. #13
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Originally posted by ubunreal69
    lol this could get funny
    it's not like we're ganna have a bust up over it!

    It's near the top of the Include function docs, but you are right in that require also is imported even if it's not needed (like in false If's), but they also differ regarding error handling apparently

  14. #14

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    Hmm, well, since the beginning of this thread i have been using INCLUDE without having to debug anything cos i dont generally make errors with those sort of things. although looping through database results is another story altogether

    BTW. chrisjk, I knew this wouldnt have turned into a big fight, but i find watching peeople sort out differences to be interesting. i actually enjoy arguing with people

  15. #15
    scoutt
    Guest
    Originally posted by ubunreal69
    Hmm, well, since the beginning of this thread i have been using INCLUDE without having to debug anything cos i dont generally make errors with those sort of things. although looping through database results is another story altogether

    BTW. chrisjk, I knew this wouldnt have turned into a big fight, but i find watching peeople sort out differences to be interesting. i actually enjoy arguing with people
    don't generally make errors? liek you are perfect or you don't code anyhting that is hard

    and most adults know how to handle things so there is no fighting, unlike most kids on this forum (mostly from the past) that think they are right all the time. I'd admit if I was wrong and chris usually knows what he is talking about so he wouldn't lie to me

  16. #16
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Originally posted by scoutt
    chris usually knows what he is talking about
    he he, not always

    I think the main idea of include/require is indeed what you said and what I said is probably just a side-issue

  17. #17

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    Originally posted by scoutt

    don't generally make errors? liek you are perfect or you don't code anyhting that is hard

    and most adults know how to handle things so there is no fighting, unlike most kids on this forum (mostly from the past) that think they are right all the time. I'd admit if I was wrong and chris usually knows what he is talking about so he wouldn't lie to me
    yeh, if you count GR12 as being full of "Kids"; i'm not as immiture as you'd think !

Posting Permissions

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



Click Here to Expand Forum to Full Width