Home  >  Article  >  Backend Development  >  Operators for PHP mobile Internet development

Operators for PHP mobile Internet development

巴扎黑
巴扎黑Original
2017-03-19 09:31:03971browse

[Introduction] 1. PHP operators PHP has a rich set of operators, most of which come directly from the C language. According to different functions, operators can be divided into: arithmetic operators, string operators, assignment operators, bit operators, conditional operators, and logical operators. There is a rich set of operators in PHP, most of which come directly from the C language. According to different functions, operators can be divided into: arithmetic operators, string operators, assignment operators, bit operators, conditional operators, and logical operators. When various operators are in the same expression, their operations have a certain priority.

(1) Arithmetic operation

+ - * / % ++ --

(2) String operator

String operator only A. (dot) is the English period. It can concatenate strings to form a new string, or it can concatenate strings with numbers, and the types will be automatically converted.

	$a="dawanganban";  
$b="123";  
echo $a.$b;   //输出结果:dawanganban123

(3) Assignment operator

	= += -= *= /= %= .=



$a="dawanganban";  
$a.=1;  
$a.=2;  
$a.=3;  
echo $a.$b;   //输出结果:dawanganban123

(4) Bit operators

& | ~ ^ 10e3fdaca48eb0367c6d60dbc98f885d>

(5) Comparison operators

> 6d267e5fab17ea8bc578f9e7e5e1570b= 942605533375fab4f17e7cc0df8aa5bf === !==

6d267e5fab17ea8bc578f9e7e5e1570b: is not equal to sum! =Same

===: Identity, equal values ​​and consistent types

! ==: Non-identity, unequal values ​​or inconsistent types

	echo 5 == "5"; //true  PHP是弱类型语言(js中的变量类似)  
echo 5 === "5";  //false  完全等于


  1. (6) Logical operations

AND(logical AND) OR(logical OR) XOR(logical exclusive OR) &&(logical AND) ||(logical OR) !(logical NOT)

	var_dump(5 && "");   //false  
var_dump(5 && "2"); //true  
var_dump(5 || ""); //true  
var_dump(0 xor 1); //true  
var_dump(0 xor 0); //false  
var_dump(1 xor 1); //false

1. PHP operators

There is a rich set of operators in PHP, most of which come directly from the C language. According to different functions, operators can be divided into: arithmetic operators, string operators, assignment operators, bit operators, conditional operators, and logical operators. When various operators are in the same expression, their operations have a certain priority.

(1) Arithmetic operations

+ - * / % ++ --

(2) String operator

There is only one string operator. (dot) is the English period. It can concatenate strings to form a new string, or it can concatenate strings with numbers, and the types will be automatically converted.

	$a="dawanganban";  
$b="123";  
echo $a.$b;   //输出结果:dawanganban123
(3) Assignment operator

	= += -= *= /= %= .=



$a="dawanganban";  
$a.=1;  
$a.=2;  
$a.=3;  
echo $a.$b;   //输出结果:dawanganban123
(4) Bit operators

& | ~ ^ 10e3fdaca48eb0367c6d60dbc98f885d>

(5) Comparison operator

> 6d267e5fab17ea8bc578f9e7e5e1570b= 942605533375fab4f17e7cc0df8aa5bf === !==

a8093152e673feb7aba1828c43532094: is not equal to sum! =Same

===: Identity, the values ​​are equal and the types are consistent

! ==: non-identity, values ​​are not equal or types are inconsistent

	echo 5 == "5"; //true  PHP是弱类型语言(js中的变量类似)  
echo 5 === "5";  //false  完全等于

  1. (6) Logical operations

  2. AND(logical AND) OR(logical OR) XOR(logical exclusive OR) &&(logical AND) ||(logical OR) !(logical NOT)

	var_dump(5 && "");   //false  
var_dump(5 && "2"); //true  
var_dump(5 || ""); //true  
var_dump(0 xor 1); //true  
var_dump(0 xor 0); //false  
var_dump(1 xor 1); //false

The above is the detailed content of Operators for PHP mobile Internet development. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn