PHP arithmetic operators

Source: Internet
Author: User

PHP arithmetic operators

operator name Description Example Results
X + y Add X and Y's and 2 + 2 4
X-y Reducing The difference between x and Y 5-2 3
X * y By The product of X and Y 5 * 2 10
X/Y Except Quotient of X and Y 15/5 3
X% y Modulo (remainder of division) The remainder of x divided by Y 5% 2
10% 8
10% 2
1
2
0
-X Take counter X inverse + t
A. B collocated Connect two strings "Hi". "Ha" Hiha

The following example shows the different results obtained using different arithmetic operators:

<?php $x = 10; $y =6;echo ($x + $y); Output 16echo ($x-$y); Output 4echo ($x * $y); Output 60echo ($x/$y); Output 1.6666666666667 Echo ($x% $y); Output 4?>

Run

Related reading:

PHP strstr determine if a string exists in a string

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

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

PHP two string comparison function strncasecmp How to use a detailed

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

PHP arithmetic operators

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.