How can I tell if the current page is the index page?
INDEX PAGE?
basename(PHP_SELF)
Define what you mean by "index page", please.
I just want to know if a URL contains "index". I can use $PHP_SELF to get the current url but how do know if it contains "index"?
if(basename($_SERVER['SCRIPT_FILENAME']) == 'index.php') {
Thanks NogDog!
Tracy
I was initially thinking along similar lines, but with the use of FILE instead:
if( basename(__FILE__) == 'index.php' ) {
Not to hijack this thread, but why does this magic constant utilise back slashes instead of forward slashes in the path?
nrg_alpha;10928782 wrote:I was initially thinking along similar lines, but with the use of FILE instead:
if( basename(__FILE__) == 'index.php' ) {
That will work, too, with the restriction that it must be in the main file -- if it's in an included file, then it will use the name of that include file.
Not to hijack this thread, but why does this magic constant utilise back slashes instead of forward slashes in the path?
I believe it will use whichever type of directory separator is native to the OS where it is running (back-slash on Windoze, forward-slash on *N?X).
NogDog;10928788 wrote:That will work, too, with the restriction that it must be in the main file -- if it's in an included file, then it will use the name of that include file.
I believe it will use whichever type of directory separator is native to the OS where it is running (back-slash on Windoze, forward-slash on *N?X).
Ah ok. Thanks for the explanation. Yeah, in this case, I wasn't intending FILE as an include, but just using basename to fetch the current file name.
@ Windoze