PHP mobile Internet Development notes (3) -- Operators
I. PHP Operators
PHP has a rich set of operators, most of which are directly from the C language. Operators can be divided into Arithmetic Operators, string operators, value assignment operators, bitwise operators, conditional operators, and logical operators. When operators are in the same expression, their operations have a certain priority.
(1) arithmetic operations
+-*/% + + --
(2) string Operators
The character string operator has only one. (point), which is an English ending. It can connect a string to form a new string, or connect a string to a number. The type is automatically converted.
View source print?
1.
$a
=
dawanganban
;
2.
$b
=
123
;
3.
echo
$a
.
$b
;
// Output result: dawanganban123(3) value assignment operator
View source print?
01.
= += -= *= /= %= .=
02.
03.
04.
05.
$a
=
dawanganban
;
06.
$a
.=1;
07.
$a
.=2;
08.
$a
.=3;
09.
echo
$a
.
$b
;
// Output result: dawanganban123(4) bitwise operators & | ~ ^ <>
(5) Comparison Operators
><>==! = <>==! =
<>: Not equal to or! = Same
===: Constant, equal value and consistent type
! ==: Non-constant, with inconsistent values or types
- View source print?
1.echo 5 == 5; // True PHP is a weak language (variables in js are similar) 2.echo 5 === 5; // False is completely equal(6) logical operations
AND (logical AND) OR (logical OR) XOR (logical OR) & (logical AND) | (logical OR )! (Non-logical)
View source print?1.var_dump(5 && ); //false 2.var_dump(5 && 2); //true 3.var_dump(5 || ); //true 4.var_dump(0 xor 1); //true 5.var_dump(0 xor 0); //false 6.var_dump(1 xor 1); //false