PHP operator (c) "Assignment operator" Example explained

Source: Internet
Author: User
Tags php operator
What is the PHP assignment operator?

The most basic form of the assignment operator is "=", where the "=" is not "equal to", is the meaning of the assignment, it is the function of the simple point is to assign value to the variable, for example, $a=10, meaning to give 10 $ A, so that the value of $ A is 10.
PHP operators related to extension knowledge: 1. " The PHP arithmetic operator is detailed in "2." An example of a PHP string operator explains "

This is, of course, just the most basic assignment operator. In addition to the most basic "=" assignment operators, we have other forms of assignment operators, which we call compound assignment operators, as shown in the following table

Operator Description Example Equivalent to Significance
= Assign value $a =b $a =b Assign the value on the right to the left
+= Add $a +=b $a = $a +b Add the right value to the left
-= Reducing $a-=b $a = $a-b Reduce the value on the right to the left
*= By $a *=b $a = $a *b Multiply the value on the right by the left
/= Except $a/=b $a = $a/b Divide the value on the right by the left
.= Connection character $a. =b $a = $a. b Multibyte the right word to the left
% Take the remainder $a%=b $a = $a +%b Take the left side of the value to the right of the remainder

PHP Assignment Operator Instance

The code is as follows

<?php$a=20;echo $a. " <br/> "; Output 20$y=20; $y + = 80;echo $y. " <br/> "; Output 100$z=50; $z-= 25;echo $z. " <br/> "; Output 25$i=5; $i *= 5;echo $i. " <br/> "; Output 25$j=10; $j/= 5;echo $j. " <br/> "; Output 2$k=15; $k%= 4;echo $k. " <br/> "; Output 3?>

Operation Result:

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.