<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                1、構造器屬性提升 ~~~php <?php namespace myphp; class City{ public $name; public $city; // 構造方法 public function __construct($name, $city){ $this->name = $name; $this->city = $city; } public function fun(){ // 在類中使用偽變量: "$this" 引用當前類的成員變量 return '姓名:'.$this->name.',城市:'.$this->city.'<hr/>'; } } // 實例化 $obj = new City('張三','包頭市'); echo $obj->fun(); ~~~ 更少的樣板代碼來定義并初始化屬性 ~~~php <?php namespace myphp; class City{ // 構造方法 public function __construct(public $name,public $city){ } public function fun(){ // 在類中使用偽變量: "$this" 引用當前類的成員變量 return '姓名:'.$this->name.',城市:'.$this->city.'<hr/>'; } } // 實例化 $obj = new City('李四','包頭市'); echo $obj->fun(); ~~~ 2、聯合類型 類型 描述 bool 布爾型:true 和 false int 整型:負數 - 0 - 無限大 float 浮點型:帶小數的數字(負數 - 0 - 無限大) string 字符串:漢字、英文、符號、其它國家語言 array 數組:一組數據的集合 object 對象:存儲數據和有關如何處理數據的信息 mixed 新增:任何類型 ~~~php <?php namespace myphp; class City{ // 構造方法 public function __construct( public string $name, public string $city, public int|float $num ){ } public function fun(){ return '姓名:'.$this->name.',城市:'.$this->city.',今年是'.$this->num.'年<hr/>'; } } // 實例化 $obj = new City('李四','包頭市',2022); echo $obj->fun(); ~~~ 3、mixed 類型 描述 mixed 新增:任何類型 ~~~php <?php namespace myphp; class City{ // 構造方法 public function __construct( public mixed $name, public mixed $city, public mixed $num ){ } public function fun(){ return '姓名:'.$this->name.',城市:'.$this->city.',今年是'.$this->num.'年<hr/>'; } } // 實例化 $obj = new City('李四','包頭市',2022); echo $obj->fun(); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看