|
PHP Control Structures
|
|
PHP Function handling Functions
|
|
PHP Operators
|
|
PHP Logical Operators
|
|
PHP Arithmetic Operators
|
|
PHP Incrementing/Decrementing Operators
|
|
PHP Bitwise Operators
|
|
PHP Comparison Operators
|
|
PHP Math Functions
|
|
PHP XML Manipulation Functions
|
|
PHP Network Functions
|
|
PHP Error Handling Functions
|
|
More PHP Cheat Sheet
|
|
Example
|
Name
|
Result
|
|
$a and $b
|
And
|
TRUE if both $a and $b are TRUE.
|
|
$a or $b
|
Or
|
TRUE if either $a or $b is TRUE.
|
|
$a xor $b
|
Xor
|
TRUE if either $a or $b is TRUE, but not both.
|
|
! $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.
|
|
Example
|
Name
|
Result
|
|
-$a
|
Negation
|
Opposite of $a.
|
|
$a + $b
|
Addition
|
Sum of $a and $b.
|
|
$a - $b
|
Subtraction
|
Difference of $a and $b.
|
|
$a * $b
|
Multiplication
|
Product of $a and $b.
|
|
$a / $b
|
Division
|
Quotient of $a and $b.
|
|
$a % $b
|
Modulus
|
Remainder of $a divided by $b.
|
|
Example
|
Name
|
Effect
|
|
++$a
|
Pre-increment
|
Increments $a by one, then returns $a.
|
|
$a++
|
Post-increment
|
Returns $a, then increments $a by one.
|
|
--$a
|
Pre-decrement
|
Decrements $a by one, then returns $a.
|
|
$a--
|
Post-decrement
|
Returns $a, then decrements $a by one.
|
|
Example
|
Name
|
Result
|
|
$a & $b
|
And
|
Bits that are set in both $a and $b are set.
|
|
$a | $b
|
Or (inclusive or)
|
Bits that are set in either $a or $b are set.
|
|
$a ^ $b
|
Xor (exclusive or)
|
Bits that are set in $a or $b but not both are set.
|
|
~ $a
|
Not
|
Bits that are set in $a are not set, and vice versa.
|
|
$a << $b
|
Shift left
|
Shift the bits of $a $b steps to the left (each step means "multiply by two")
|
|
$a >> $b
|
Shift right
|
Shift the bits of $a $b steps to the right (each step means "divide by two")
|
|
Example
|
Name
|
Result
|
|
$a == $b
|
Equal
|
TRUE if $a is equal to $b after type juggling.
|
|
$a === $b
|
Identical
|
TRUE if $a is equal to $b, and they are of the same type.
|
|
$a != $b
|
Not equal
|
TRUE if $a is not equal to $b after type juggling.
|
|
$a <> $b
|
Not equal
|
TRUE if $a is not equal to $b after type juggling.
|
|
$a !== $b
|
Not identical
|
TRUE if $a is not equal to $b, or they are not of the same type.
|
|
$a < $b
|
Less than
|
TRUE if $a is strictly less than $b.
|
|
$a > $b
|
Greater than
|
TRUE if $a is strictly greater than $b.
|
|
$a <= $b
|
Less than or equal to
|
TRUE if $a is less than or equal to $b.
|
|
$a >= $b
|
Greater than or equal to
|
TRUE if $a is greater than or equal to $b.
|
|
Comparison
|
with
|
Various Types
|
|
Type of Operand 1
|
Type of Operand 2
|
Result
|
|
null or string
|
string
|
Convert NULL to "", numerical or lexical comparison
|
|
bool or null
|
anything
|
Convert to bool, FALSE < TRUE
|
|
object
|
object
|
Built-in classes can define its own comparison, different classes are uncomparable, same class - compare properties the same way as arrays (PHP 4), PHP 5 has its own explanation
|
|
string, resource or number
|
string, resource or number
|
Translate strings and resources to numbers, usual math
|
|
array
|
array
|
Array with fewer members is smaller, if key from operand 1 is not found in operand 2 then arrays are uncomparable, otherwise - compare value by value (see following example)
|
|
array
|
anything
|
array is always greater
|
|
object
|
anything
|
object is always greater
|
|
PHP Predefined Variables
|
|
PHP Array Functions
|
|
PHP String Functions
|
|
PHP Date/Time Functions
|
|
PHP Calendar Functions
|
|
PHP PCRE Functions (REGEX)
|
|
PHP Mail Functions
|
|
PHP MySQL Functions
|
|
PHP Filesystem Functions
|
|
PHP Directory Functions
|
|
PHP FTP Functions
|
|
PHP ZIP Functions
|
|
PHP Filter Functions
|
|
PHP Misc Functions
|
Thank you!
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.