Fourth Chapter _php Basic Grammar (2) _php tutorial

Source: Internet
Author: User
1. Declaration of constants

In PHP, define constants using the Define () function to implement

2. Magic Constants

< td=""> < td=""> < td=""> < td=""> < td="">
Returns the current line number in the file
__file__ Returns the full path and filename of the file
__dir__ Returns the directory where the file resides
__function__ Returns the name of the function when it is defined
__class__ Returns the name of the class when it is defined
__mthod__ Returns the name of the method to which the class was defined

The test code is as follows:

< span=""> 
  
  < span="">     < span="">< span="">< span="">         < span="">'

The name of this function is: '. < span="">< span="">< span="">< span="">< span="">< c27>< span=""> '

This is the first '. < span="">.' Yes. '< span="">< span="">< span=""> '

The absolute path to this file is: '. < span="">< span="">< span="">< span="">< span=""> ? >

3. Reference Assignment

Access the same variable content with a different variable name, and the other changes as the value of one of the variables changes.

4. Logical operators

With && or | |  Non -! XOR

< span=""> 
  
  < span="">     < span="">=< span="">< span="">< span="">< span="">=< span=""> < span="">< span="">< span="">< span="">(< span=""> < span="">); < span=""> '
'< span="">< span="">< span="">(< span="">< span="">); < span=""> '
'< span="">< span="">< span="">(< span="">< span="">); < span=""> '
'< span="">< span="">< span="">(! < span="">); < span=""> '
< span=""> ' ?>< span="">

5. Comparison operators

① equals = = $a = = $b when a value of $ A equals the value of $b, returns True, otherwise false

congruent = = = $a = = = $b when a value of $ A equals the value of $b, and $ A is equal to the type of $b, returns True, otherwise false

③ Range! = or <>

not congruent! ==

  6. Bitwise operators

< td=""> < td=""> < td="">
Bitwise-AND & is 1 position 1, the rest is 0
Bitwise OR | There is a position of 1 for 1 and the rest to 0
Bitwise XOR OR ^ Different positions are 1 and the rest is 0
Bitwise non- ~ 1 of the position is 0,0 position is 1
Move left << BITS move n times to the left, which is equal to 2 times each move
Move right >> BITS move n times to the right, which is equivalent to dividing by 2 per move

 
  < span="">     < span="">=123< span="">  =321< span="">< span=""> < span="">  < span="">  < span=""> ' $a & $b = < span=""> '. (  < span="">   & < span=""> ). '     
< span=""> " < span=""> $a |< span=""> $b = '. (< span=""> | < span="">).'
< span=""> " < span=""> $a ^ $b = '.< span=""> (< span=""> ^ < span="">).'
< span=""> " < span=""> ~ $a = '.< span=""> (~< span="">).'
< span=""> "< span=""> $a <<4= ." < span=""> (< span=""><<4). '
< span=""> "< span=""> $b >>4= ." < span=""> (< span="">>>4). '
< span=""> ' ?>< span="">

7. String operators

(.) and (. =) and {}

8. Array operators (omitted)

9. Type operator

Type operators are commonly used by instanceof to determine whether a variable belongs to an instance of a class.

< span=""> 
  
  < span="">     < span="">< span="">< span="">         < span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">=< span="">< span="">< span="">< span="">((< span=""> instanceof A)); < span=""> '
< span="">'< span=""> (( instanceof B));< span="">< span=""> < span=""> '
< span=""> ' ?>< span="">

10. Error control operator @

http://www.bkjia.com/PHPjc/626587.html www.bkjia.com true http://www.bkjia.com/PHPjc/626587.html techarticle 1. Declaration of constants in PHP, define constants using the Define () function to implement 2. Magic constant Returns the current line number in the file __file__ returns the full path and file name of the file __dir ...

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