6/2/2005

php : Syntax of composite if statement

By Susan — [ ] Reported at 2:11 am, 06/02/2005.

Operator Description

== Is equal to
=== Is identical to (is equal and is the same data type)
!= Is not equal to
!== Is not identical to
< Is less than
<= Is less than or equal to
> Is greater than
>= Is greater than or equal to
————————————————
Logical Operators in PHP

Operator Name Description

! a - NOT - True if a is not true

a && b AND - True if both a and b are true

a || b - OR - True if either a or b is true

a and b - AND - True if both a and b are true

a xor b - XOR - True if a or b is true, but not both

a or b - OR - True if either a or b is true

There are two different ways of performing a logical AND or OR in PHP. The difference between and and && (and between or and ||) is the precedence used to evaluate expressions.

Consider :

a or b and c
a || b and c

In the former condition, the and takes precedence and is evaluated first. The overall condition is true if a is true or if both b and c are true.

elseif Versus else if

In PHP you can also write elseif as two words: else if. The way PHP interprets this variation is slightly different, but its behavior is exactly the same.

Print This Article | E-Mail
Pages (1) : [1]

1 2 3 4 5 6 7 8 9 10 11 12 13
Powered by Proweblog.com