Home > Backend Development > PHP Problem > What is the calculation formula for addition, subtraction, multiplication and division in php

What is the calculation formula for addition, subtraction, multiplication and division in php

WBOY
Release: 2023-03-15 15:54:01
Original
4310 people have browsed it

In PHP, you can use arithmetic operators to implement calculation formulas for addition, subtraction, multiplication and division. Arithmetic operators are used to operate on the values ​​on both sides of the symbol. The calculation formulas are "x y", "x - y", "x * y" and "x / y" respectively represent the sum, difference, product and quotient of two numbers.

What is the calculation formula for addition, subtraction, multiplication and division in php

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.

What is the calculation formula for addition, subtraction, multiplication and division in php

PHP Arithmetic operators are similar to operators in mathematics, both have addition, subtraction, multiplication and division.

The most basic arithmetic operators

Add

Subtract -

Multiple *

Division/

Get The remaining %

examples are as follows:

<?php

$x = 100;

$y = 150;

echo ($x + $y)."<br>"; // 输出 250

echo ($x - $y)."<br>"; // 输出 -100

echo ($x * $y)."<br>"; // 输出 1500

echo ($x / $y)."<br>"; // 输出 0.6666666666667

echo ($x % $y); // 输出 1

?>
Copy after login

Output results:

What is the calculation formula for addition, subtraction, multiplication and division in php

Recommended learning: "PHP Video tutorial

The above is the detailed content of What is the calculation formula for addition, subtraction, multiplication and division in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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