久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php數(shù)組如何轉(zhuǎn)換json字符串

      php數(shù)組轉(zhuǎn)換json字符串的方法:首先創(chuàng)建一個(gè)php示例文件;然后定義一組數(shù)組數(shù)據(jù);最后通過(guò)“json_encode($color)”方法將數(shù)組轉(zhuǎn)換成json字符串即可。

      php數(shù)組如何轉(zhuǎn)換json字符串

      推薦:《PHP視頻教程》

      PHP中 數(shù)組/對(duì)象轉(zhuǎn)成JSON字符串

      代碼如下:

      <?php   //php語(yǔ)言生成json字符串 //json_encode(數(shù)組/對(duì)象);   //① 索引數(shù)組-->JavaScript數(shù)組 $color = array('gold','yellow','blue'); echo json_encode($color)."<br />";// ["gold","yellow","blue"]   //② 關(guān)聯(lián)數(shù)組-->json字符串 $city = array('shandong'=>'jinan','henan'=>'zhengzhou','hebei'=>'shijiazhuang'); echo json_encode($city)."<br />";//{"shandong":"jinan","henan":"zhengzhou","hebei":"shijiazhuang"}   //③ 索引關(guān)聯(lián)數(shù)組-->json字符串 $city2 = array('shandong'=>'jinan','henan'=>'zhengzhou','shenyang','hebei'=>'shijiazhuang'); echo json_encode($city2)."<br />";//{"shandong":"jinan","henan":"zhengzhou","0":"shenyang","hebei":"shijiazhuang"}   //④ 對(duì)象生成json信息-->json字符串 //   (只會(huì)序列化"成員屬性",不會(huì)序列化"成員方法") class Person{     //類內(nèi)部的成員屬性需要有修飾符(var/public/protected/private),其是固定語(yǔ)法     public $color = "yellow";     var $height = 170;     function run(){         echo "is running";     } } $tom = new Person(); echo json_encode($tom);  //{"color":"yellow","height":170}

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)