detecting "index.php" versus "index.php?var=xxx"

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
glennnall
Forum Newbie
Posts: 13
Joined: Wed Jan 27, 2010 7:54 am

detecting "index.php" versus "index.php?var=xxx"

Post by glennnall »

i'm running code on what i only want to be the HOME page, but the current site it built using GET variables with index.php

needless to say, the home page is accessed either as domain.com/ or domain.com/index.php - i'm hoping someone can show me how to check for this condition, that it is only index.php without anything further

I'm only slightly familiar with $_SERVER['uri'], etc... So i don't know just what to ask.

thanks for anyone's help.

Glenn
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: detecting "index.php" versus "index.php?var=xxx"

Post by Gargoyle »

Code: Select all

if(!count($_GET))
{
echo 'no variables';
}
glennnall
Forum Newbie
Posts: 13
Joined: Wed Jan 27, 2010 7:54 am

Re: detecting "index.php" versus "index.php?var=xxx"

Post by glennnall »

awesome, worked. thanks much
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: detecting "index.php" versus "index.php?var=xxx"

Post by Weirdan »

Code: Select all

if (empty($_SERVER['QUERY_STRING'])) {
   echo 'index.php accessed';
} else {
   echo 'index.php?<something> accessed';
}
Post Reply