Two basic questions: (1) can constants in the class be directly accessed in the form of dual-colons for instances? What is the actual situation? & Lt ;? PhpclassA {& nbsp; constmm10; & nbsp; function _ construct () {& nbsp; echoself: mm; & nbsp ;}} echo $ a: mm ;? & 2 basic questions
Two problems:
(1)
Can constants in the class be directly accessed in the form of dual-colons for instances? What is the actual situation?
Class {
Const mm = 10;
Function _ construct (){
Echo self: mm;
}
}
Echo $ a: mm;
?>
(2)
Static members are called through instances. Is this a good way? Why
Class {
Public static $ mm = 10;
}
$ A = new;
Echo $ a: $ mm;
?>
------ Solution --------------------
PHP code
Class B {const mm = 10; function _ construct () {echo self: mm ;}} echo B: mm; #10 class C {public static $ mm = 11 ;}$ class_a = new C; echo $ class_a ::$ mm; #11