【无标题】

【无标题】,第1张

【无标题】

 1 class Person
 2 {
 3     const HOST = 'localhost';
 4 
 5     public function say(){
 6         echo 'hello';
 7     }
 8 }
 9 
10 echo Person::HOST;

1 final class Person

2 {
3     const HOST = 'localhost';
4 
5     public function say(){
6         echo 'hello';
7     }
8 }

1 class Person
2 {
3     const HOST = 'localhost';
4 
5     final public function say(){
6         echo 'hello';
7     }
8 }

  1.  1 class Person
     2 {
     3     public $name;
     4     static public $num;
     5 
     6     public function __construct($n){
     7         $this->name = $n;
     8         Person::$num++;
     9     }
    10 }
    11 new Person('user1');
    12 new Person('user2');
    13 new Person('user3');
    14 
    15 echo Person::$num; # 3

     1 # 
     2 
     3 class Person
     4 {
     5     public $name;
     6 
     7     public function __construct($n){
     8         $this->name = $n;
     9     }
    10 
    11     public function say(){
    12         echo "

    my name is {$this->name}

    "; 13 } 14 15 static public function sum($i,$j){ 16 return $i+$j; 17 } 18 } 19 20 echo Person::sum(5,25);

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5619999.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存