当前位置:编程学习 > php >>

php常用操作符

最常见的PHP赋值运算,算术运算符,联合经营,比较运算符和逻辑运算符。每个类型分别讨论如下。

赋值运算符

在PHP基本赋值运算符是“=”。这意味着,左边的操作数“=”获取设置为值的右侧“=”。

算术运算符

Operator Example Result
+ 4 + 2 6
- 4 - 2 2
* 4 * 2 8
/ 4 / 2 2
% 4 % 2 0
++ x = 4; x++; x = 5
-- x = 4; x--; x = 3

联合运营商

你可以结合赋值运算符算术运算符组成一个联合运营商。联合运营商如下:

Operator Example Meaning
+= y += x y = y + x
-= y -= x y = y - x
*= y *= x y = y * x
/= y /= x y = y / x
%= y %= x y = y % x

比较运算符

Operator Meaning
== is equal to
!= is not equal to
> is greater than
>= is greater than or equal to
< is less than
<= is less than or equal to

逻辑运算符

Operator Meaning
|| or
&& and
and and
or or
xor xor
! not
补充:Php教程,Php入门 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,