<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 屬性 類的變量成員叫做“屬性”,或者叫做“字段”、“特征”,在本文檔統一稱為“屬性”。屬性聲明是由關鍵字 public,protected 或者 private 開頭,然后跟一個普通的變量聲明來組成。屬性中的變量可以初始化,但是初始化的值是常數,這里的常數是指 PHP 腳本在編譯階段時就可以的到其值,而不依賴于運行時的信息才能求值。 > **Note**: 為了向后兼容 PHP 4,PHP 5 聲明屬性依然可以直接使用關鍵字 *var* 來替代(或者附加于)*public*,*protected* 或 *private*。但是已不再需要 *var* 了。在 PHP 5.0 到 5.1.3,*var* 會被認為是廢棄的,而且拋出 **`E_STRICT`** 警告,但是 5.1.3 之后就不再認為是廢棄,也不會拋出警告。 如果直接使用 *var* 聲明屬性,而沒有用 *public*,*protected* 或 *private* 之一,PHP 5 會將其視為 *public*。 在類的成員方法里面,可以用 -> (對象運算符):`$this->property` (其中 property 是該屬性名)這種方式來訪問非靜態屬性。靜態屬性則是用 :: (雙冒號):`self::$property`來訪問。更多靜態屬性與非靜態屬性的區別參見 [Static 關鍵字](https://www.php.net/manual/zh/language.oop5.static.php)。 當一個方法在類定義內部被調用時,有一個可用的偽變量 `$this`。`$this`是一個到主叫對象的引用(通常是該方法所從屬的對象,但如果是從第二個對象[靜態](https://www.php.net/manual/zh/language.oop5.static.php)調用時也可能是另一個對象)。 **Example #1 屬性聲明** ``` <?php class?SimpleClass { ???//?錯誤的屬性聲明 ???public?$var1?=?'hello?'?.?'world'; ???public?$var2?=?<<<EOD hello?world EOD; ???public?$var3?=?1+2; ???public?$var4?=?self::myStaticMethod(); ???public?$var5?=?$myVar; ???//?正確的屬性聲明 ???public?$var6?=?myConstant; ???public?$var7?=?array(true,?false); ???//在?PHP?5.3.0?及之后,下面的聲明也正確 ???public?$var8?=?<<<'EOD' hello?world EOD; } ?> ``` 跟 [heredocs](https://www.php.net/manual/zh/language.types.string.php#language.types.string.syntax.heredoc) 不同,[nowdocs](https://www.php.net/manual/zh/language.types.string.php#language.types.string.syntax.nowdoc) 可在任何靜態數據上下文中使用,包括屬性聲明。 **Example #2 示例:使用 nowdoc 初始化屬性** ``` <?php class?foo?{ ???//?自?5.3.0?起 ???public?$bar?=?<<<'EOT' bar EOT; } ?> ```
                  <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>

                              哎呀哎呀视频在线观看