<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之旅 廣告
                __toString() 是快速獲取對象的字符串信息的魔術方法,它在直接輸出對象引用時自動調用。 __toString() 的作用: 當我們調試程序時,需要知道是否得出正確的數據,比如打印一個對象時,看看這個對象都有哪些屬性,其值是什么。如果定義了toString方法,在打印對象體時,就會自動調用該方法,格式化輸出這個對象所包含的數據。 ``` <?php class Person{ private $name = ""; function __construct($name = ""){ // 定義構造函數 $this->name = $name; } public function say(){ // 定義公共方法 echo "hello,".$this->name."!"; } function __toString(){ // 定義獲取字符串的魔術方法 return "__toString:".$this->name.'!'; } } $blog = new Person('blog'); $blog->say(); // 輸出:hello,blog! echo $blog; // 輸出:__toString:blog! ?> ``` 如果沒有定義__toString() 方法,則執行echo語句時,會報錯。 Catchable fatal error: Object of class Person could not be converted to string in /usercode/file.php on line 16
                  <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>

                              哎呀哎呀视频在线观看