PHP arithmetic operators, php arithmetic operators_PHP tutorial

WBOY
Release: 2016-07-12 08:51:37
Original
885 people have browsed it

PHP arithmetic operator, php arithmetic operator

PHP arithmetic operator

运算符 名称 描述 实例 结果
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

The following examples demonstrate different results obtained using different arithmetic operators:

<?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

Run

Related reading:

php strstr determines whether a string exists in another string

php stristr() function finds the first occurrence of a string in another string

php strchr() function finds the first occurrence of a string in another string

Detailed explanation of how to use php comparison function strncasecmp between two strings

php strcasecmp compares two strings for equality (compares the size of two strings)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1129455.htmlTechArticlePHP arithmetic operator, php arithmetic operator PHP arithmetic operator operator name description instance result x y plus x and y The sum of 2 2 4 x - y minus the difference between x and y 5 - 2 3 x * y times the sum of x...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template