See php Manual version after the remarks, php2015-03-19_PHP tutorial

Source: Internet
Author: User
See php manual after the remarks, php2015-03-19. See php manual after the remarks, php2015-03-19 class and object-basic concepts: 1, #############################: class from PHP5.5, keyword class can also be used for the analysis of class name to see the php manual remarks, php2015-03-19

Class and object> basic concepts:
1 ,#############################
: Class
Since PHP 5.5, the keyword class can also be used for parsing class names. You can use ClassName: class to obtain a string that contains the fully qualified name of the class ClassName. This is especially useful for classes that use namespaces.
Example #7 class name resolution as stated in the docs is:
Namespace NS {
Class ClassName {
}
Echo ClassName: class;
}
?>
The above routine will output:
NS \ ClassName


2 ,#############################
Just to be clear: the correct way of validating a classname, as stated in the docs is:
$ Valid = preg_match ('/^ [a-zA-Z _ \ x7f-\ xff] [a-zA-Z0-9 _ \ x7f-\ xff] * $/', $ className );

3 ,#############################
The variables in the property can be initialized, but the initialization value must be a constant. the constant here means that the PHP script can obtain the value during the compilation phase, the value can be evaluated only by running information.
PHP 5.3.0 added support for Nowdoc declared class attributes. heredoc that does not contain variables is also possible. if it contains variables, an error occurs.


New static () follows the inheritance relationship, and new is a subclass.
New self () will not be inherited. new is the class where the word self is located.


###
As of PHP 5.6 you can finally define constant using math expressions, like this one:

Class MyTimer {
Const SEC_PER_DAY = 60*60*24;
}

?>

###
Since PHP 5.3.3, methods with the same name as the class name in the namespace are no longer used as constructors. This change does not affect classes that are not in the namespace.
Namespace Foo;
Class Bar {
Public $;
Public function Bar (){
$ This-> a = 'to where ';
}
Public function getA (){
Return $ this->;
}
}
$ Bar = new Bar ();
Echo $ bar-> getA (); // null; output to here if the namespace is removed;



###
From PHP 5.3.0, classes can be referenced through Variables. The value of this variable cannot be a keyword (such as self, parent, or static ).




With sorting:
Self, parent, and static
Public, protected, or private)

Classes and objects-basic concepts: 1 ,#############################:: class from PHP 5.5, the keyword class can also be used for parsing class names...

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.