Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-29-2008, 02:09 PM   PM User | #1
zodehala
Regular Coder

 
Join Date: Dec 2007
Posts: 269
Thanks: 28
Thanked 0 Times in 0 Posts
zodehala can only hope to improve
booleon problem

PHP Code:
$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)
zodehala is offline   Reply With Quote
Old 02-29-2008, 02:12 PM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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
PHP Code:
$c true;
if (!
$c){ // if $c is false
    
echo "false";
}else{
    echo 
"true";

or
PHP Code:
$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
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||

Last edited by _Aerospace_Eng_; 02-29-2008 at 02:14 PM..
_Aerospace_Eng_ is offline   Reply With Quote
Users who have thanked _Aerospace_Eng_ for this post:
zodehala (02-29-2008)
Old 02-29-2008, 03:34 PM   PM User | #3
zodehala
Regular Coder

 
Join Date: Dec 2007
Posts: 269
Thanks: 28
Thanked 0 Times in 0 Posts
zodehala can only hope to improve
many many thanx
zodehala is offline   Reply With Quote
Old 02-29-2008, 03:37 PM   PM User | #4
rafiki
Senior Coder

 
rafiki's Avatar
 
Join Date: Aug 2006
Location: Floating around somewhere...
Posts: 2,034
Thanks: 18
Thanked 42 Times in 42 Posts
rafiki will become famous soon enough
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
__________________
Get Firefox Now
rafiki is offline   Reply With Quote
Users who have thanked rafiki for this post:
zodehala (02-29-2008)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:26 AM.


Advertisement
Log in to turn off these ads.