久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='cGTs1'><style id='cGTs1'><dir id='cGTs1'><q id='cGTs1'></q></dir></style></legend>
    <tfoot id='cGTs1'></tfoot>

  • <small id='cGTs1'></small><noframes id='cGTs1'>

          <bdo id='cGTs1'></bdo><ul id='cGTs1'></ul>
        <i id='cGTs1'><tr id='cGTs1'><dt id='cGTs1'><q id='cGTs1'><span id='cGTs1'><b id='cGTs1'><form id='cGTs1'><ins id='cGTs1'></ins><ul id='cGTs1'></ul><sub id='cGTs1'></sub></form><legend id='cGTs1'></legend><bdo id='cGTs1'><pre id='cGTs1'><center id='cGTs1'></center></pre></bdo></b><th id='cGTs1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cGTs1'><tfoot id='cGTs1'></tfoot><dl id='cGTs1'><fieldset id='cGTs1'></fieldset></dl></div>

        PHP foreach by reference 在遍歷對象數(shù)組時會導致奇怪

        PHP foreach by reference causes weird glitch when going through array of objects(PHP foreach by reference 在遍歷對象數(shù)組時會導致奇怪的故障)
          • <bdo id='pOsVV'></bdo><ul id='pOsVV'></ul>
                <legend id='pOsVV'><style id='pOsVV'><dir id='pOsVV'><q id='pOsVV'></q></dir></style></legend>
                  <i id='pOsVV'><tr id='pOsVV'><dt id='pOsVV'><q id='pOsVV'><span id='pOsVV'><b id='pOsVV'><form id='pOsVV'><ins id='pOsVV'></ins><ul id='pOsVV'></ul><sub id='pOsVV'></sub></form><legend id='pOsVV'></legend><bdo id='pOsVV'><pre id='pOsVV'><center id='pOsVV'></center></pre></bdo></b><th id='pOsVV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pOsVV'><tfoot id='pOsVV'></tfoot><dl id='pOsVV'><fieldset id='pOsVV'></fieldset></dl></div>
                  <tfoot id='pOsVV'></tfoot>

                    <tbody id='pOsVV'></tbody>

                • <small id='pOsVV'></small><noframes id='pOsVV'>

                  本文介紹了PHP foreach by reference 在遍歷對象數(shù)組時會導致奇怪的故障的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個對象數(shù)組.對象主要有一堆屬性,因為這些是元數(shù)據(jù)對象.

                  I have an array of objects. The objects mainly have a bunch of properties because these are meta-data objects.

                  所以就像$objects[] 就像一堆具有以下屬性的項目:object->item1、object->item2

                  so it is like $objects[] is like a bunch of items that have properties like: object->item1, object->item2, etc.

                  我想為每個對象添加一些東西,所以...

                  I want to add something to each of these objects, so...

                  foreach ($objects as &$object) {
                    $object->newItem=(something I compute);
                  }
                  

                  然后,我想將這些對象顯示為 html 中的列表.所以,我去:

                  then later, I want to display these objects as a list in html. So, I go:

                  foreach ($objects as $object) {
                    <li><?php object output stuff here ?></li>
                  }
                  

                  好的.現(xiàn)在,它工作正常,除了最后一個對象被丟棄并且倒數(shù)第二個對象顯示兩次.跆拳道??

                  ok. Now, it works fine, except the last object is discarded and the second to last object is displayed twice. WTF??

                  這對你有意義嗎?

                  推薦答案

                  如果你通過引用迭代,之后總是取消設置迭代變量:

                  If you iterate by reference, always unset the iteration variable afterwards:

                  foreach ($objects as &$object) {
                        // some code
                  }
                  unset($object);
                  

                  摘自 foreach 文檔:

                  Excerpt from the foreach documentation:

                  即使在 foreach 循環(huán)之后,對 $value 和最后一個數(shù)組元素的引用仍然存在.建議用unset()銷毀.

                  Reference of a $value and the last array element remain even after the foreach loop. It is recommended to destroy it by unset().

                  如果您想了解為什么您的代碼的行為方式如此,這里有一些進一步的閱讀:引用和foreach

                  If you want to understand why your code behaves the way it behaves, here is some further reading: References and foreach

                  這篇關于PHP foreach by reference 在遍歷對象數(shù)組時會導致奇怪的故障的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環(huán))
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數(shù))
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“l(fā)ocalhost的訪問被拒絕)
                    • <bdo id='sRiC3'></bdo><ul id='sRiC3'></ul>
                      <legend id='sRiC3'><style id='sRiC3'><dir id='sRiC3'><q id='sRiC3'></q></dir></style></legend>
                      1. <small id='sRiC3'></small><noframes id='sRiC3'>

                        <tfoot id='sRiC3'></tfoot>

                            <tbody id='sRiC3'></tbody>
                          • <i id='sRiC3'><tr id='sRiC3'><dt id='sRiC3'><q id='sRiC3'><span id='sRiC3'><b id='sRiC3'><form id='sRiC3'><ins id='sRiC3'></ins><ul id='sRiC3'></ul><sub id='sRiC3'></sub></form><legend id='sRiC3'></legend><bdo id='sRiC3'><pre id='sRiC3'><center id='sRiC3'></center></pre></bdo></b><th id='sRiC3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sRiC3'><tfoot id='sRiC3'></tfoot><dl id='sRiC3'><fieldset id='sRiC3'></fieldset></dl></div>

                            主站蜘蛛池模板: 一区二区高清在线观看 | 精久久久 | 日韩免费一区 | 日韩中文字幕一区 | 久久精品国产一区二区电影 | 精品乱码一区二区 | 国产精品久久久久久久免费大片 | 国产又色又爽又黄又免费 | 免费福利视频一区二区三区 | 亚洲一区二区在线 | 狠狠操狠狠干 | 国产精品1区2区 | 国产一区二区三区在线观看免费 | 99久久久久 | 久久中文字幕在线 | 亚洲国产免费 | 黄色成人在线网站 | 国产黄色大片网站 | 天堂综合网| 欧美久久久久久久 | 国产精品区二区三区日本 | 日日骚网| 精品国产乱码久久久久久蜜退臀 | 日韩在线免费 | 久久久久久久夜 | 亚洲成人一区二区 | 中文字幕在线网 | 亚洲免费在线 | 欧美一区二区三区久久精品 | 日韩免费视频一区二区 | 国产精品国产亚洲精品看不卡15 | 人人干人人玩 | 久久久女女女女999久久 | 久久久久久久久国产 | 日韩精品激情 | 高清成人免费视频 | 免费在线一区二区 | 成人国产在线视频 | 免费的色网站 | 免费午夜剧场 | 欧美日韩国产在线 |