PHP notes = & gt; var

Source: Internet
Author: User
When accessing the member variables or methods in the PHP class, if the referenced variables or methods are declared as const (defining constants) or static (declaring static), the operator must be used:: If the referenced variable or method is not declared as const or static, the operator-must be used -. In addition, if the internal access to const from the class changes

When accessing the member variables or methods in the PHP class, if the referenced variables or methods are declared as const (defining constants) or static (declaring static), the operator must be used:: If the referenced variable or method is not declared as const or static, the operator-must be used -. In addition, if the internal access to const from the class changes

When accessing the member variables or methods in the PHP class, if the referenced variables or methods are declared as const (defining constants) or static (declaring static), the operator must be used:: If the referenced variable or method is not declared as const or static, the operator-> must be used.

In addition, if you access the const variable, static variable, or static method from inside the class, you must use self, otherwise, if the internal access from the class is not a const or static variable or method, you must use the self-referenced $ this


1: in strong language, variables, functions, and class names are case sensitive. js is case sensitive, but PHP is a bit different:


$ A = "x123 ";

$ A = "y123 ";

Echo $ a. "\ n ";

Echo $;


?>

Everyone knows the output result;



2:

Class registry {

Protected $ x = 'you ';

Function test (){

Return $ this-> x;

}

}

$ C = new Registry ();

$ C-> TEST ();

This method is case-insensitive in the class.


2:


Sometimes when var_dump is used to debug the array output, the lower-level array cannot be displayed, and the ellipsis is shown below in php. restart the service added to the xdebug node of ini. Configure the field as needed.

Xdebug. var_display_max_children = 128
Xdebug. var_display_max_data = 1024
Xdebug. var_display_max_depth = 15


3:

$ Str = "method ";

Echo $ str {0}; // The output here is m

Echo $ str {2}; // The output here is t

?>
Here {} is equivalent to [], and the effect is the same.


4:

$ A = 10; $ B = 10; $ c = 11;

$ A = $ B $ c = 19;

Echo $ c; // $ c = 19

For js:

Console. log (5 = '5' & 6 | 7 );

Change output 6 to 5 = 10, and output 7.

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.