MemoryRefresh!

Logical



Questions Answers 0%

Pages   0 from 51
Questions   0 from 84

Reset



AND operator (&& / and) - Evaluates to true if both the left and right operands evaluate to true
<?php if (isset($a) AND isset($b)) { // a and b is set } OR operator (|| / or) - Evaluates to true if either the left or right operands evaluate to true.
<?php if (isset($a) OR isset($b)) { // a, b, a and b - could be set } XOR operator (xor) - Evaluates to true if either the left and right operands evaluates to true, but not both
<?php $a = "1"; $b = "abc"; if (is_numeric($a) XOR is_numeric($b)) { echo "Only one number exists"; } // Outputs: Only one number exists It's important to understand that all logical operators onlywork with Boolean values PHP will first convert any other value to a Boolean and then perform the operation.
Questions

Related pages

Aritmetic !
String !
Comparison !
Logical !
Bitwise !


0% 100%
 
 
0 pages 51 pages
1) Check if only one variable is set





Last Review: n/a   Passed: n/a   Reviews: n/a   Next Review: n/a  


AND operator (&& / and) - Evaluates to true if both the left and right operands evaluate to true
<?php if (isset($a) AND isset($b)) { // a and b is set } OR operator (|| / or) - Evaluates to true if either the left or right operands evaluate to true.
<?php if (isset($a) OR isset($b)) { // a, b, a and b - could be set } XOR operator (xor) - Evaluates to true if either the left and right operands evaluates to true, but not both
<?php $a = "1"; $b = "abc"; if (is_numeric($a) XOR is_numeric($b)) { echo "Only one number exists"; } // Outputs: Only one number exists It's important to understand that all logical operators onlywork with Boolean values PHP will first convert any other value to a Boolean and then perform the operation.



More from Php

Basics
Variables
Operators
Function
Array
String
Streams
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com