1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. PHP中函數(shù)的使用說明

        時間:2023-03-30 22:14:58 PHP 我要投稿
        • 相關(guān)推薦

        PHP中函數(shù)的使用說明

          先用一段代碼重現(xiàn)一下問題

          乍一看,結(jié)果很讓人費解:

          復(fù)制代碼 代碼如下:

          <?php

          $string = <<<EOF

          hello

          world

          EOF;

          $data = simplexml_load_string($string);

          print_r($data);

          print_r($data->foo);

          ?>

          乍一看,結(jié)果很讓人費解:

          復(fù)制代碼 代碼如下:

          SimpleXMLElement Object

          (

          [foo] => Array

          (

          [0] => SimpleXMLElement Object

          (

          [bar] => hello

          )

          [1] => SimpleXMLElement Object

          (

          [bar] => world

          )

          )

          )

          SimpleXMLElement Object

          (

          [bar] => hello

          )

          明明print_r顯示foo是一個有兩個bar元素的數(shù)組,但是最后卻僅僅顯示了一個bar元素!

          原因其實很簡單,在如上所示simplexml_load_string的結(jié)果里,foo并不是數(shù)組,而是一個迭代對象!

          可以這樣確認:

          復(fù)制代碼 代碼如下:

          foreach ($data->foo as $v) print_r($v);

          foreach ($data->children() as $v) print_r($v);

          看來,print_r或者var_dump之類的表象并不完全可信,自己多留心吧。

        【PHP中函數(shù)的使用說明】相關(guān)文章:

        PHP5常用函數(shù)列表06-22

        最近總結(jié)的一些php信息函數(shù)06-22

        excel中if函數(shù)的使用方法09-24

        Excel中vlookup函數(shù)使用方法02-17

        excel中now函數(shù)的使用方法05-25

        簡單分析PHP中序列化用法介紹08-23

        PHP中MySQL、MySQLi和PDO的用法和區(qū)別08-29

        php高級教程06-21

        PHP可以做什么06-21

        2022年P(guān)HP入門指導(dǎo)08-11

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>