Basic syntax for PHP (ii)

Source: Internet
Author: User
Seven, PHP operators

1. Arithmetic operators

Arithmetic instructions
+ Add
- Reducing
* By
/ Except
% Take the mold

2. Assignment operators

Assignment is equivalent to a description
X =y x = y The right-hand expression sets the value for the left operand.
x + = y x = x + y Add
X-= y x = XY Reducing
X *= y x = x * y By
X/= y × = x/y Except
X%= y x = x% y Modulus

3. String operators

Operator name Example Results
. Thread connection $txt 1 = "Hello" $txt 2 = $txt 1. "World!" Now $txt 2 contains "Hello world!"
.= String Assignment $txt 1 = "Hello" $txt 1. = "world!" Now $txt 1 contains "Hello world!"

4, increment/decrement operator

Operator Name Description
+ + $x Pre-increment $x adds an increment, and then returns $x
$x + + Post-increment Return $x, then $x plus one increment
? $x Before descending $x decreases by one and then returns $x
$x? After descending Return $x, then $x minus one decrement

5. Comparison operators

Operator name Example Results
== Equals $x = = $y Returns True if $x equals $y.
=== Congruent (exact same) $x = = = $y Returns True if $x equals $y and they are of the same type.
!= Not equal to $x! = $y Returns true if $x is not equal to $y.
<> Not equal to $x <> $y Returns true if $x is not equal to $y.
!== Not congruent (completely different) $x!== $y Returns true if $x are not equal to $y and they are of different types.
> Greater than $x > $y Returns True if the $x is greater than $y.
< Greater than $x < $y Returns True if the $x is less than $y.
>= Greater than or equal to $x >= $y Returns true if $x is greater than or equal to $y.
<= Less than or equal to $x <= $y Returns True if $x is less than or equal to $y.

6. Logical operators

Operator name Example Results
and And $x and $y Returns True if both the $x and the $y are true.
Or Or $x or $y Returns true if at least one of the $x and $y is true.
Xor XOR or $x XOR $y Returns True if $x and $y have and only one is true.
&& And $x && $y Returns True if both the $x and the $y are true.
| Or $x | $y Returns true if at least one of the $x and $y is true.
! Non - ! $x Returns True if the $x is not true.

7. Array operators

Operator name Example Results
+ Joint $x + $y Union of $x and $y (but does not overwrite duplicate keys)
== Equal $x = = $y Returns true if the $x and $y have the same key/value pair.
=== Congruent $x = = = $y Returns True if $x and $y have the same key/value pairs, and the same type is the same in the order.
!= Not equal $x! = $y Returns true if $x is not equal to $y.
<> Not equal $x <> $y Returns true if $x is not equal to $y.
!== Not congruent $x!== $y Returns True if the $x is completely different from the $y.

Copyright NOTICE: This article for Lshare original article, need to reprint please contact me, have questions welcome comments or private messages.

  • 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.