Basic syntax for PHP (ii)

Source: Internet
Author: User

Seven, PHP operator 1, arithmetic operators
arithmetic Description
+ Add
- Reducing
* By
/ Except
% Take the mold
2. Assignment operators
Assign Value equivalent to 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 $txt1 = "Hello" $txt2 = $txt1. "World!" $txt2 now contains "Hello world!"
.= String Assignment $txt1 = "Hello" $txt1. = "world!" $txt1 now contains "Hello world!"
4, increment/decrement operator
operator name Description
+ +$x Pre-increment $x plus one increment, and then return $x
$x + + Post-increment Returns $x, then $x plus one increment
–$x Before descending $x minus one decrement, and then return $x
$x – After descending Returns $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 is not equal to $y and their type is not the same.
> Greater than $x > $y Returns True if $x is greater than $y.
< Greater than $x < $y Returns True if $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 $x and $y are true.
Or Or $x or $y Returns True if $x and $y have at least one 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 $x and $y are true.
| Or $x | $y Returns True if $x and $y have at least one true.
! Non - ! $X Returns True if $x is not true.
7. Array operators returns True if $ x and $ y have the same key/value pair.
operator name example result
+ Union $ x + $ y $ x and $< /span>y Union (but does not overwrite duplicate keys)
= = equality $ x = = $ y
= = = congruent $ x = = $ y if $ X and $ y have the same key/value pairs, and return true if the same type is the same in order.
! = Not equal $ x! = $ y if $ x Returns true, not equal to $ y.
<> not Equal $ x <> $ y if $ x is not equal to $ y, returns True.
!== not congruent $ x!== $ y if $x returns True if the $ y is different.

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

Basic syntax for PHP (ii)

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.