PHP operator (3) "value assignment operator" example

Source: Internet
Author: User
Tags php operator
The most basic form of the value assignment operator is "". here, "" is not "equal to", but a value assignment. its function is to assign values to variables simply, for example, $ A10 means to assign 10 to $ A, so that the value of $ A is 10. What is the php value assignment operator?

The most basic form of the value assignment operator is "=". Here "=" is not "equal to". it is a value assignment. its function is to assign values to variables simply, for example, $ A = 10 indicates that 10 is assigned to $ A, so that the value of $ A is 10.
Extensions of php operators: 1. "php arithmetic operators" 2. "php string operators"

Of course, this is only the most basic assignment operator. In addition to the most basic "=" value assignment operator, we also have other forms of value assignment operators, called composite value assignment operators, as shown in the following table.

Operator Description Example Equivalent Meaning
= Assignment $ A = B $ A = B Assign the value on the right to the left
+ = Add $ A + = B $ A = $ a + B Add the value on the right to the left
-= Subtraction $ A-= B $ A = $ a-B Reduce the value on the right to the left
* = Multiplication $ A * = B $ A = $ a * B Multiply the value on the right by the value on the left
/= Division $ A/= B $ A = $ a/B Divide the value on the right by the value on the left
. = Connection character $ A. = B $ A = $ a. B Add the character on the right to the left
% Returns the remainder. $ A % = B $ A = $ a + % B Returns the remainder of the left value pair to the right.

Php assignment operator instance

The code is as follows:

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

Running result:

The above example is the basic application of the value assignment operator, and we hope you can further develop and use it on the basis. The following section describes the bitwise operators in the PHP operators ".

The above is the details of the PHP operator (3) "value assignment operator" instance. For more information, see other related articles in the first PHP community!

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.