If there a way to force PHP to only match a case sensitive version of isset($_GET['query'])?
- John
Matthew1980
12:50 pm on Oct 12, 2010 (gmt 0)
Hi there JAB_Creations,
I guess that would be a job for preg_match after isset() only checks to see if a variable or property has state and only returns false if the variable is NULL.
Preg_match() without the 'i' so that the match is sensitive..
Hope that makes sense.
Cheers, MRb
coopster
12:55 pm on Oct 12, 2010 (gmt 0)
It should be case sensitive. Did you mean case insensitive? Try this and see which word shows up when you click the link(s).
<a href="?QUERY=1">QUERY</a><br> <a href="?query=1">query</a><br> <?php if (isset($_GET['QUERY'])) { print "QUERY."; } else if (isset($_GET['query'])) { print "query."; } exit;
JAB Creations
1:06 pm on Oct 12, 2010 (gmt 0)
Thank you both for the replies...
Matthew, whoa! I do not what to use regular expressions to resolve this issue if at all possible!
coopster, I'm trying to prevent duplicate content if someone links to my site using multiple variations of letter casing. Thankfully on my CMS I was able to replace MySQL's = operator with LIKE BINARY which resolved the vast majority of situations where this issue could have occurred. However on my forum I want to prevent the f (forum) and t (thread) queries from working unless they are lowercase only. Even if this does not create a duplicate content issue with Google I still would like to to figure this out.
- John
coopster
1:19 pm on Oct 12, 2010 (gmt 0)
You can check for precise GET variables expected and if they do not exist, 404. Variables are case sensitive by default, including the array indexes in the superglobals.
Matthew1980
1:33 pm on Oct 12, 2010 (gmt 0)
Hi all,
Woop's - I seem to have completely missed the point on this one! Just ignore me in this instance, it's been a heavy week! And it's only Tuesday..
Cheers, MRb
JAB Creations
1:37 pm on Oct 12, 2010 (gmt 0)
AH-HA! Thanks coopster, turns out that $_GET variables are case sensitive. Originally I simply used isset($_GET['f']) which both f and F were catching as true. By using isset($_GET['F']) before isset($_GET['f']) I was able to resolve the issue! Thanks!
- John
JAB Creations
1:39 pm on Oct 12, 2010 (gmt 0)
Matthew, just got an email just after I posted my last reply (hence double post); no problem and thanks for participating and maybe you got something out of it. :)