PHP 运算符
2016-02-24 11:20
531 查看
运算符用于对值进行运算. 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
算数运算符 运算符 说明 例子 结果 + 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 中使用的各种运算符: |
运算符 | 说明 | 例子 | 结果 |
---|---|---|---|
+ | 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%2 10%8 10%2 | 1 2 0 |
++ | Increment | x=5 x++ | x=6 |
-- | Decrement | x=5 x-- | x=4 |
赋值运算符
运算符 | 说明 | 例子 |
---|---|---|
= | x=y | x=y |
+= | x+=y | x=x+y |
-= | x-=y | x=x-y |
*= | x*=y | x=x*y |
/= | x/=y | x=x/y |
.= | x.=y | x=x.y |
%= | x%=y | x=x%y |
比较运算符
运算符 | 说明 | 例子 |
---|---|---|
== | is equal to | 5==8 returns false |
!= | is not equal | 5!=8 returns true |
> | is greater than | 5>8 returns false |
< | is less than | 5<8 returns true |
>= | is greater than or equal to | 5>=8 returns false |
<= | is less than or equal to | 5<=8 returns true |
逻辑运算符
运算符 | 说明 | 例子 |
---|---|---|
&& | and | x=6 y=3 (x < 10 && y > 1) returns true |
|| | or | x=6 y=3 (x==5 || y==5) returns false |
! | not | x=6 y=3 !(x==y) returns true |
相关文章推荐
- PHP基础教程:PHP $_GET,$_POST,$…
- PHP设计模式之简单投诉页面实例
- liunx 安装FTP 设置ftp帐号
- 【ZendFramework】ZendFramework 2 数据库操作小记
- 【ZendFramework】ZendFramework 2 数据库操作小记
- PHP---ajax
- php常用加密算法
- Php 删除数组后几个元素
- Thinkphp模板的使用
- [我的PHP之旅] YII框架学习 01.安装与配置
- PHP引用(&)详解
- 高性能的PHP日志系统 SeasLog
- PHP初学之超全局变量
- others2bool.php
- yii2 应用组件 components
- YII2 modules 模块化
- sftp 常用命令
- Laravel报class does not exist的一种可能原因及其解决办法
- php 文件压缩
- PHP之类补充