...

View Full Version : booleon problem



zodehala
02-29-2008, 02:09 PM
$c = true;
if ($c= 'false'){
echo "false";
}else{
echo "true";
}

even if $c is TRUE or FALSE output is FALSE why ? (in IE and FF too)

_Aerospace_Eng_
02-29-2008, 02:12 PM
You are trying to compare $c to a string which you can't do and you aren't using the proper comparison operator (===). Try this

$c = true;
if (!$c){ // if $c is false
echo "false";
}else{
echo "true";
}
or

$c = true;
if ($c === false){ // if $c is false
echo "false";
}else{
echo "true";
}
Read the manual on comparison operators. http://us2.php.net/operators.comparison

zodehala
02-29-2008, 03:34 PM
many many thanx

rafiki
02-29-2008, 03:37 PM
using $c = 'false' in your if statement you are setting it to 'false' not checking,
= is set
== is compare value
=== is compare value and type



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum