Re: Logical OR in assignment




Larry Garfield wrote:
The single pipe | is bitwise OR, yes. You're probably thinking of this
construct:

a = b || c

Which is a valid and common default-value idiom in Python and Javascript, but
I don't think works in PHP. (If it does, someone please correct me because
I'd like to use it. <g>)


PHP will allow you to do the following...

if ( $answer == "yes" || $answer == "yep") {

echo "affirmative";

}

..... At least, I hope it does b/c I use it all the time ;-)

.



Relevant Pages

  • Re: The "new age" of html?
    ... level and is now competing with php, javascript, python and asp. ... If you want something to run on a standard Apache or IIS server ...
    (alt.html)
  • Re: Bitwise operators. Differences from javascript and PHP.
    ... In Python and Ruby - it's ok. ... But i need to get in Python same value as in PHP and Javascript. ...
    (comp.lang.python)
  • Re: The "new age" of html?
    ... level and is now competing with php, javascript, python and asp. ...
    (alt.html)
  • Re: syntax for assigning to an array
    ... In Javascript, would the equivalent code be this? ... in JavaScript is an implicit Array constructor call. ... PHP grounds ... It is much more likely that this feature was borrowed from Python. ...
    (comp.lang.javascript)
  • XMLHttpRequest and AJAX for PHP programmers
    ... Although the concept isn't entirely new, XMLHttpRequest technology is ... There are too many PHP programmers avoiding any ... work with javascript beyond simple form validation, ...
    (comp.lang.php)