The logical operators in php lest combinations of booleans.
php locical operators is important for understanding conditional statement .
The or operator -which is indicated by two pipe characters( || )
or simply the characters or teturns true if either the left or the right operand is true. So
true|| false
returns true.
The and operator, which is indicated by either two ampersand characters( &&) or the characters and returns true only if both the left and right operands are true.So
true && false Returns false
It's unlikely that yu would use a logical operator to test booleans constants, however. It would make more sens to test two or more expressions that resolve to a boolean. for example
( $x > 2 ) && ( $x<16)
would return true if $x contained a vlaue greater than 2 and smaller than 15,
we include the parentheses to make the code easier to read.
Logical operators
Operator Name Returns true if..... example Result
|| Or Left or right is true true || false true
or Or Left or right is true true || false true
xor Xor Left or right is true but not both true xor true false
&& and left and right are true true && false false
and And left and right are true false && true false
! Not The single operand is not true !true false
if you want to know about javascript visit Javascript
true|| false
returns true.
The and operator, which is indicated by either two ampersand characters( &&) or the characters and returns true only if both the left and right operands are true.So
true && false Returns false
It's unlikely that yu would use a logical operator to test booleans constants, however. It would make more sens to test two or more expressions that resolve to a boolean. for example
( $x > 2 ) && ( $x<16)
would return true if $x contained a vlaue greater than 2 and smaller than 15,
we include the parentheses to make the code easier to read.
Logical operators
Operator Name Returns true if..... example Result
|| Or Left or right is true true || false true
or Or Left or right is true true || false true
xor Xor Left or right is true but not both true xor true false
&& and left and right are true true && false false
and And left and right are true false && true false
! Not The single operand is not true !true false
if you want to know about javascript visit Javascript
Post a Comment