Elementary Introduction to PHP Syntax (2) _php tutorial

Source: Internet
Author: User
Tags learn php learn php programming php programming
Before the discussion is only PHP data type, so-called "sharpening does not mistake chopping wood work", Lay a good PHP foundation to better learn PHP programming.
There is little difference between the expression and the operator in PHP and the C language, which is now listed below:
┌─────┬─────────┬──────────┐
│ Symbols │ Operators │ Examples │
├─────┼─────────┼──────────┤
│+│ addition │ $a + $b │
├─────┼─────────┼──────────┤
│-│ Subtraction │ $a-$b │
├─────┼─────────┼──────────┤
│*│ multiplication │ $a * $b │
├─────┼─────────┼──────────┤
│/│ Division │ $a/$b │
├─────┼─────────┼──────────┤
│%│ remainder │ $a% $b │
├─────┼─────────┼──────────┤
│++│ Increment │ $a + + or + + $a │
├─────┼─────────┼──────────┤
│--│ Decrease │ $a--or--$a │
├─────┼─────────┼──────────┤
│==│ equals │ $a ==10│
├─────┼─────────┼──────────┤
│===│ is absolutely equal to │ $a ===10│
├─────┼─────────┼──────────┤
│!=│ not equal to │ $a!=10│
├─────┼─────────┼──────────┤
│<│ less than │ $a <9│
├─────┼─────────┼──────────┤
│>│ greater than │ $a >8│
├─────┼─────────┼──────────┤
│<=│ less than or equal to │ $a <=10│
├─────┼─────────┼──────────┤
│>=│ greater than or equal to │ $a >=1│
├─────┼─────────┼──────────┤
│=│ equality assignment operator │ $a =0│
├─────┼─────────┼──────────┤
│+=│ addition specified operator │ $a +=5│
├─────┼─────────┼──────────┤
│-=│ subtraction specified operator │ $a-=1│
├─────┼─────────┼──────────┤
│*=│ multiplication specified operator │ $a *=2│
├─────┼─────────┼──────────┤
│/=│ division specified operator │ $a/=5│
├─────┼─────────┼──────────┤
│%=│ remainder specified operator │ $a%=7│
├─────┼─────────┼──────────┤
│.=│ string specifying operator │ $a. = "Hello" │
├─────┼─────────┼──────────┤
│&│ and │ $a & $b │
├─────┼─────────┼──────────┤
│| │ or │ $a | $b │
├─────┼─────────┼──────────┤
│^│xor│ $a ^ $b │
├─────┼─────────┼──────────┤
│~│ Non-│~ $a (take 1 of the complement) │
├─────┼─────────┼──────────┤
│<<│ shift left │ $a << $b │
├─────┼─────────┼──────────┤
│>>│ right Shift │ $a >> $b │
├─────┼─────────┼──────────┤
│and or &&│ with │ $a and $b or $a&& $b │
├─────┼─────────┼──────────┤
│or or | | │ or │ $a or $b or $a| | $b │
├─────┼─────────┼──────────┤
│xor│xor│ $a xor $b │
├─────┼─────────┼──────────┤
│! │ non-│! $a │
└─────┴─────────┴──────────┘
┌───┬────────────┐
│ Symbols │ Meaning │
├───┼────────────┤
│$│ variable │
├───┼────────────┤
Pointer to the │&│ variable (before the variable) │
├───┼────────────┤
│->│ methods or properties of an object │
├───┼────────────┤
│=>│ element values of an array │
├───┼────────────┤
│? : │ ternary operator │
└───┴────────────┘
Compare it with the C language. There's just one more "." This operator. Its role is to make two strings connected, as shown in the following example, the result is hello,my baby.
$a = "Hello,";
$b = "My Baby.";
echo $a. $b;
?>
There is also a symbol that makes PHP powerful. This is "$". It is used before a variable, indicating that it is a variable, such as $ A, $b, and so on. And where does it work? This Queensland unlimited is the variable of the variable.
The following example:
$a = "Go";
$ $a = "here";
echo $a;
echo $ $a;
Echo $go;
?>
The results shown are:
Go
Here
Here
In fact, adding a "$" before a variable means that the contents of the variable are used as a new variable name. This is unique to PHP, and sometimes simplifies the program.


http://www.bkjia.com/PHPjc/532533.html www.bkjia.com true http://www.bkjia.com/PHPjc/532533.html techarticle before the discussion is only PHP data type, so-called "sharpening does not mistake chopping wood work", Lay a good PHP foundation to better learn PHP programming. There is little difference between the expression and the operator in PHP and the C language ...

  • Related Article

    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.