Re: Variable Strangeness

From: Date: Wed, 21 Feb 2001 16:55:48 +0000
Subject: Re: Variable Strangeness
Groups: php.general 
Request: Send a blank email to php-general+get-40997@lists.php.net to get a copy of this message
Addressed to: Jason Murray <jason@jwebmedia.com> php-general@lists.php.net ** Reply to note from Jason Murray <jason@jwebmedia.com> 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

« previous php.general (#40997) next »