Table of Contents
PHP 算术运算符,php算术运算符
Home php教程 php手册 PHP 算术运算符,php算术运算符

PHP 算术运算符,php算术运算符

Jun 13, 2016 am 08:39 AM
arithmetic operators

PHP 算术运算符,php算术运算符

PHP 算术运算符

运算符 名称 描述 实例 结果
x + y x 和 y 的和 2 + 2 4
x - y x 和 y 的差 5 - 2 3
x * y x 和 y 的积 5 * 2 10
x / y x 和 y 的商 15 / 5 3
x % y 模(除法的余数) x 除以 y 的余数 5 % 2
10 % 8
10 % 2
1
2
0
- x 取反 x 取反 - 2  
a . b 并置 连接两个字符串 "Hi" . "Ha" HiHa

以下实例演示了使用不同算术运算符得到的不同结果:

<?php 
$x=10; 
$y=6;
echo ($x + $y); // 输出16
echo ($x - $y); // 输出4
echo ($x * $y); // 输出60
echo ($x / $y); // 输出1.6666666666667 
echo ($x % $y); // 输出4 
?>
Copy after login

运行

相关阅读:

php strstr 判断一个字符串是否存在于里一个字符串中

php stristr() 函数查找字符串在另一字符串中的第一次出现

php strchr() 函数查找字符串在另一字符串中的第一次出现

php 两个字符串之间的比较函数strncasecmp使用方法详解

php strcasecmp 比较两个字符串是否相等(比较两个字符串的大小)

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)