PHP 运算符

来源:互联网 发布:如何申请域名注册机关 编辑:程序博客网 时间:2024/04/30 18:57
运算符用于对值进行运算. PHP 运算符 本部分列出了在 PHP 中使用的各种运算符:算数运算符 运算符 说明 例子 结果 + Addition x=2 x+2 4 - Subtraction x=2 5-x 3 *Multiplication x=4 x*5 20 / Division 15/5 5/2 3 2.5 % Modulus(division remainder) 5

 运算符用于对值进行运算.

PHP 运算符

本部分列出了在 PHP 中使用的各种运算符:

算数运算符

运算符说明例子结果+Additionx=2
x+24-Subtractionx=2
5-x3*Multiplicationx=4
x*520/Division15/5
5/23
2.5%Modulus (division remainder)5%2
10%8
10%21
2
0++Incrementx=5
x++x=6--Decrementx=5
x--x=4

赋值运算符

运算符说明例子=x=yx=y+=x+=yx=x+y-=x-=yx=x-y*=x*=yx=x*y/=x/=yx=x/y.=x.=yx=x.y%=x%=yx=x%y

比较运算符

运算符说明例子==is equal to5==8 returns false!=is not equal5!=8 returns true>is greater than5>8 returns false<is less than5<8 returns true>=is greater than or equal to5>=8 returns false<=is less than or equal to5<=8 returns true

逻辑运算符

运算符说明例子&&andx=6
y=3

(x < 10 && y> 1) returns true

||orx=6
y=3

(x==5 || y==5) returns false

!notx=6
y=3

!(x==y) returns true

0 0
原创粉丝点击