Logical Operators for PHP, VBScript, Javascript

In the past, I have worked with javascript, asp/vbscript, coldfusion, and a little bit of perl. Now, I've started working with php. I have to admit, it can get confusing at times (especially if you have to keep going back and forth between them). So, I decided I'm going to start putting together comparison charts for javascript, vbscript, and php (maybe perl and coldfusion down the road, but for now just the three scripting languages). My first chart will be for logical operators.

operator vbscript javascript php
AND and && and
&&
OR or || or
||
not NOT ! !
XOR xor xor

Operator Precedence:

  • vbscript:     not     and     or     xor
  • javascript:     !     &&     ||
  • php:     !     &&     ||     and     xor     or

VBScript and Null:

  • null and true = null
  • null and false = false
  • null and null = null
  • null or true = true
  • null or false = null
  • null or null = null
  • not null = null
  • null xor true = null
  • null xor false = null
  • null xor null = null

References:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>