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 ?>
运行
相关阅读:
php strstr 判断一个字符串是否存在于里一个字符串中
php stristr() 函数查找字符串在另一字符串中的第一次出现
php strchr() 函数查找字符串在另一字符串中的第一次出现
php 两个字符串之间的比较函数strncasecmp使用方法详解
php strcasecmp 比较两个字符串是否相等(比较两个字符串的大小)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools