you made a comparison in your code. it returned true which is 1.

what are you trying to do anyway? if you want to compare and print it only
if it's yes then do:

$confidential = 0;
echo "$confidential " . $confidential ? 'yes' : '';



Sincerely,

 Maxim Maletsky
 Founder, Chief Developer

 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 22, 2001 1:56 AM
To: Jason Murray; [EMAIL PROTECTED]
Subject: Re: [PHP] Variable Strangeness


Addressed to: Jason Murray <[EMAIL PROTECTED]>
              [EMAIL PROTECTED]

** Reply to note from Jason Murray <[EMAIL PROTECTED]> Wed, 21 Feb 2001
11:37:40 -0600
>
> Hi,
>
> I came across this:
>
>       $confidential = 0;
>       echo "$confidential " . ($confidential == "yes");
>
> In which "0 1" was printed.
>

$confidential = 0;   #  Numeric 0

That explains the 0.


$confidential == "yes"

This is a little tricky.  The numeric value of 'yes' is 0, so it
evaluates to the same thing as  0 == 0, which is true.  True has a
numeric value of 1, although all values besides 0 are considered true.


You might want to look at the === operator which checks that both the
value and the type of the operands is identical.

   http://www.php.net/manual/en/html/language.operators.comparison.html




Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to