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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                在5.4中, Json新增了一個JsonSerializable接口, 任何實現了這個接口的類, 需要定義一個jsonSerialize()方法, 這個方法會在對這個**類的對象做Json化**的時候被調用, 這個時候你就可以在這個方法內 , 隨意調整最終的Json化的結果: ``` class JsonTest implements JsonSerializable { private $a, $b; public function __construct($a, $b) { $this->a = $a; $this->b = $b; } public function jsonSerialize() { return $this->a + $this->b; } } //json_encode JsonTest類的對象時觸發jsonSerialize()方法 echo json_encode(new JsonTest(23, 42)); //65 ``` Json的這種默認只對屬性做操作的做法有的時候是不能解決問題的, 比如我們希望通過私有成員來做一些計算得到最后的Json化數據, 又或者我們希望用一個字符串來代替一個object. 在以前, 那你只能自己拼湊Json串 ``` $data = array( new stdClass(); new JsonTest(1,2), new JsonTest(3,4), array(5,6) ); echo json_encode($data); //[{},3,7,[5,6]] ```
                  <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>

                              哎呀哎呀视频在线观看