note 1926 deleted from language.operators.logical by colder

From: Date: Fri, 20 Apr 2007 15:37:57 +0000
Subject: note 1926 deleted from language.operators.logical by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-125692@lists.php.net to get a copy of this message
Note Submitter: dante at hearme dot com ---- [Ed Note: The reason for this is because || has a higher precedence than =, and = has a higher precedence than 'or'. See http://www.php.net/manual/en/language.operators.precedence.php --irc-html@php.net] I wanted to do something like this: $choice1 = ""; $choice2 = "dog"; $default = "other"; $val = $choice1 || $choice2 || $default; but then $val1 will only contain 1 or 0. Instead I did this: $choice1 = ""; $choice2 = "dog"; $default = "other"; $val = $choice1 or $choice2 or $default; now $val contained the string "dog". That's weird that 'or' is different from '||'...and I would think that the '||' should be smart enough to handle strings...the way PERL does. Guess not. Maybe it's a design choice.

« previous php.notes (#125692) next »