See php manual after the 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:
<? Php
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:
<? Php
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.
<? Php
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)