PHP operators for PHP learning

Source: Internet
Author: User
Tags php operator
PHP operators for PHP learning. Read the PHP operators for PHP learning. The following describes the arithmetic, string, logic, and comparison operators of PHP3. 1. arithmetic operator +: $ a + $ B plus $ a plus $ B-: $ a-$ B minus $ a minus $ B *: $ a * $ B multiply by $ a by $ B/: $ a/$ B, except for $ a divided by $ B %: $ a PHP operator

Next, let's take a look at the arithmetic, string, logic, comparison, and other operators of PHP3.
1. arithmetic operators
+: $ A + $ B plus $ a plus $ B-: $ a-$ B minus $ a minus $ B *: $ a * $ B multiply by $ a by $ B/: $ a/$ B, except for $ a divided by $ B %: $ a % $ B modulo $ a divided by the remainder of $ B if both operands are integer values (strings are converted to integer values), Division ("/") returns the integer value (the value of the entire division ). If any of the operands is a floating point value, the floating point division is performed.
2 String operators
The string operator is only a string connector ("."). $ A = "Hello"; $ B = $ a. "World! "; // Now $ B =" Hello World! "
3. value assignment operator
The basic assignment operator is "= ". The value of a value assignment expression is the assigned value. For example, the value of expression $ a = 3 is 3. This allows you to do complex things like this: $ a = ($ B = 4) + 5; // Now $ a equals 9, $ B is 4. In addition to the basic value assignment, there are also "composite operators ". You can perform variable self-composite operations on all binary numbers and strings.
Example: =: $ a = 3; + =: $ a + = 5; // Set $ a to 8, that is, $ a = $ a + 5; $ B = "Hello ";.: $ B. = "There! "; // Set $ B to" Hello There! ", Just like $ B = $ B." There! ";
4. bitwise operators
Bit operations allow you to set or reset the specified data. &: Operation. if $ a & $ B and $ a and $ B are both set, the result is set to a bit. |: or operation, $ a | $ B, $ a, or $ B if one of them is set, the result is set ~ : Non-calculation ,~ $ A if not $ a is not set, the result is set.
5. logical operators
And: $ a and $ B. If both $ a and $ B are true, the result is true or: $ a or $ B or $ a or $ B. If one of them is true, the result is true xor: $ a xor $ B is different. if $ a and $ B are not both true, the result is true! :! If $ a is not false, the result is true &: $ a & $ B. If both $ a and $ B are true, the result is true. |: $ a | when one of $ B, $ a, or $ B is true, and the result is true, "and" and "or" operations have two types of operators, that is, they have different priorities. 6. Comparison operators, just like names, allow you to compare two values. ==: $ A ===$ B equals $ a equals $ B and the result is true! =: $! = $ B not equal to $ a not equal to $ B the result is true <: $ a <$ B less than $ a less than $ the result is true>: $ a> $ B result greater than $ a result greater than $ B is true <=: $ a <= $ B result less than or equal to $ a result less than or equal to $ B result is true >=: $ a >=$ B greater than or equal to $ a greater than or equal to $ B, the result is true.


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.