how do you write if the url containes DESC?

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
grudz
Forum Commoner
Posts: 68
Joined: Thu Dec 04, 2003 12:52 pm

how do you write if the url containes DESC?

Post by grudz »

how would the that if statement

Code: Select all

if ($_SERVER['HTTP_REFERER'] == "%DESC%");
Farrier
Forum Newbie
Posts: 12
Joined: Thu Mar 25, 2004 10:39 am

Post by Farrier »

if (strpos($_SERVER['HTTP_REFERER'], 'DESC') !== false) {
// Note we must test exactly against false here.

Use stripos() if you want a case-insensitive match.
grudz
Forum Commoner
Posts: 68
Joined: Thu Dec 04, 2003 12:52 pm

Post by grudz »

it gives me a parse error
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Post by TheBentinel.com »

Code: Select all

<?php

if (strpos($_SERVER['HTTP_REFERER'], 'DESC') !== false) 
{
  echo "not false";
}
else
{
  echo "is false";
}

?>
Does that error if you use it just that way? I didn't test it, but it looks right.
Post Reply