...

View Full Version : Why isn't the if comparision working?



cyphix
05-11-2004, 11:21 AM
This always seems to return as true..



if (strtolower($searchperson) == strtolower('$first') or strtolower('$last') or strtolower('$first $last')) {


Any ideas why?

firepages
05-11-2004, 12:24 PM
anything within single quotes is ignored by PHP ... e.g.


<?
$first='blah ';
echo $first;
echo "$first";
echo '$first';
?>
e.g.
<?
if (
strtolower($searchperson) == strtolower( $first ) ||
strtolower($searchperson) == strtolower( $last ) ||
strtolower($searchperson) == strtolower("$first $last")
){
//match
}
?>

cyphix
05-11-2004, 02:09 PM
I initially tried it with no quotes around them but then I got errors so then I tried single & double quotes around them & both those always returned true results every time.

cyphix
05-11-2004, 02:21 PM
Hmmmm.... I tried doing it that way before on the single line but it didn't work; however that works.

Cheers!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum