Click to See Complete Forum and Search --> : retrieve filename
ubunreal69
Feb 17th, 2002, 03:56 AM
how can i retrieve the filename of the current file and get a result like "index.php" ?????
ubunreal69
Feb 17th, 2002, 03:59 AM
the ASP equivalent would be <%
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_
chrisjk
Feb 17th, 2002, 11:09 AM
print $PHP_SELF;
ubunreal69
Feb 17th, 2002, 06:07 PM
thanx chrisjk, i'll give it a try. u wouldnt happen top know how to do include scripts in php woud ya ?
chrisjk
Feb 17th, 2002, 08:39 PM
yep, you can include other php scripts like this
require('./other.php3');that could include functions and whatnot.
chrisjk
Feb 17th, 2002, 08:45 PM
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
ubunreal69
Feb 18th, 2002, 06:41 PM
ok, so they work exacly the same except one displays errors if there is any ?
chrisjk
Feb 18th, 2002, 08:48 PM
that is correct
scoutt
Feb 25th, 2002, 03:52 PM
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).
chrisjk
Feb 25th, 2002, 04:44 PM
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.
ubunreal69
Feb 25th, 2002, 07:18 PM
Originally posted by chrisjk
don't be so hasty scoutt...
lol :D this could get funny ;)
scoutt
Feb 25th, 2002, 10:33 PM
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.
chrisjk
Feb 26th, 2002, 10:58 AM
Originally posted by ubunreal69
lol :D 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 :)
ubunreal69
Feb 27th, 2002, 06:09 AM
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 :D
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 ;)
scoutt
Feb 27th, 2002, 10:22 AM
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 :D
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 :p
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 ;)
chrisjk
Feb 27th, 2002, 11:23 AM
Originally posted by scoutt
chris usually knows what he is talking abouthe 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
ubunreal69
Feb 27th, 2002, 06:11 PM
Originally posted by scoutt
don't generally make errors? liek you are perfect or you don't code anyhting that is hard :p
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 ! :( :rolleyes:
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.