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

    <small id='LTXs4'></small><noframes id='LTXs4'>

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

      <bdo id='LTXs4'></bdo><ul id='LTXs4'></ul>
      <tfoot id='LTXs4'></tfoot>

      在 foreach 循環(huán)中聲明的 PHP 變量是否在每次迭代時

      Are PHP variables declared inside a foreach loop destroyed and re-created at each iteration?(在 foreach 循環(huán)中聲明的 PHP 變量是否在每次迭代時被銷毀和重新創(chuàng)建?)
      • <small id='yTgyt'></small><noframes id='yTgyt'>

          <tbody id='yTgyt'></tbody>
        <tfoot id='yTgyt'></tfoot>
          • <bdo id='yTgyt'></bdo><ul id='yTgyt'></ul>

          • <legend id='yTgyt'><style id='yTgyt'><dir id='yTgyt'><q id='yTgyt'></q></dir></style></legend>

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

              1. 本文介紹了在 foreach 循環(huán)中聲明的 PHP 變量是否在每次迭代時被銷毀和重新創(chuàng)建?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                如果我在 foreach 循環(huán)中聲明一個變量,例如:

                If I declare a variable inside a foreach loop, such as:

                foreach($myArray as $myData) {
                    $myVariable = 'x';
                }
                

                PHP 是否銷毀它,并在每次迭代時重新創(chuàng)建它?換句話說,在性能方面這樣做是否更明智:

                Does PHP destroy it, and re-creates it at each iteration ? In other words, would it be smarter performance-wise to do:

                $myVariable;
                foreach($myArray as $myData) {
                    $myVariable = 'x';
                }
                

                預(yù)先感謝您的見解.

                推薦答案

                在你的第一個例子中:

                foreach($myArray as $myData) {
                    $myVariable = 'x';
                }
                

                $myVariable 在第一次迭代期間創(chuàng)建,然后在每次進(jìn)一步迭代時覆蓋.在離開你的腳本、函數(shù)、方法的范圍之前,它不會隨時被銷毀......

                $myVariable is created during the first iteration and than overwritten on each further iteration. It will not be destroyed at any time before leaving the scope of your script, function, method, ...

                在你的第二個例子中:

                $myVariable;
                foreach($myArray as $myData) {
                    $myVariable = 'x';
                }
                

                $myVariable 在任何迭代之前創(chuàng)建并設(shè)置為 null.在每次迭代期間 if 將被覆蓋.在離開你的腳本、函數(shù)、方法的范圍之前,它不會隨時被銷毀......

                $myVariable is created before any iteration and set to null. During each iteration if will be overwritten. It will not be destroyed at any time before leaving the scope of your script, function, method, ...

                我沒有提到主要區(qū)別.如果 $myArray 為空 (count($myArray) === 0) $myVariable被創(chuàng)建在您的第一個示例中,但在您的第二個示例中,它的值為 null.

                I missed to mention the main difference. If $myArray is empty (count($myArray) === 0) $myVariable will not be created in your first example, but in your second it will with a value of null.

                這篇關(guān)于在 foreach 循環(huán)中聲明的 PHP 變量是否在每次迭代時被銷毀和重新創(chuàng)建?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                MySQLi prepared statement amp; foreach loop(MySQLi準(zhǔn)備好的語句amp;foreach 循環(huán))
                Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務(wù)器還是從同一用戶獲取記錄?)
                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 查詢:用查詢結(jié)果填充變量)
                MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“l(fā)ocalhost的訪問被拒絕)
              2. <i id='ACx2Q'><tr id='ACx2Q'><dt id='ACx2Q'><q id='ACx2Q'><span id='ACx2Q'><b id='ACx2Q'><form id='ACx2Q'><ins id='ACx2Q'></ins><ul id='ACx2Q'></ul><sub id='ACx2Q'></sub></form><legend id='ACx2Q'></legend><bdo id='ACx2Q'><pre id='ACx2Q'><center id='ACx2Q'></center></pre></bdo></b><th id='ACx2Q'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ACx2Q'><tfoot id='ACx2Q'></tfoot><dl id='ACx2Q'><fieldset id='ACx2Q'></fieldset></dl></div>

                    <tbody id='ACx2Q'></tbody>

                  <small id='ACx2Q'></small><noframes id='ACx2Q'>

                  • <bdo id='ACx2Q'></bdo><ul id='ACx2Q'></ul>

                      <tfoot id='ACx2Q'></tfoot><legend id='ACx2Q'><style id='ACx2Q'><dir id='ACx2Q'><q id='ACx2Q'></q></dir></style></legend>
                        • 主站蜘蛛池模板: 久久亚洲一区二区三区四区 | 久久久久久久久久性 | 国产精品69毛片高清亚洲 | 日韩av成人 | 视频在线亚洲 | 亚洲一区二区黄 | 中文字幕亚洲欧美 | 国产精品一级 | av看片网| 欧美日韩福利视频 | 九九精品网| 中文字幕一区二区三区四区 | 欧美精品在欧美一区二区少妇 | 夜夜精品浪潮av一区二区三区 | 精品久久久久久久 | 欧美在线精品一区 | 亚洲高清视频一区 | 国产精品久久精品 | 精品蜜桃一区二区三区 | 91 久久| 日韩成人在线播放 | 国产精品日韩欧美一区二区 | 99久久精品免费看国产四区 | 夜夜爽99久久国产综合精品女不卡 | 午夜久久久久久久久久一区二区 | 99久9| 美女在线视频一区二区三区 | 国产精品久久久久久久一区探花 | 欧美狠狠操 | 91社区在线观看高清 | 国产精品视频二区三区 | 日本理论片好看理论片 | 欧美日韩亚洲在线 | 蜜桃一区二区三区 | 最新黄色在线观看 | 国产精品久久久久久久久久久免费看 | 在线欧美一区 | 99亚洲国产精品 | 欧美男人天堂 | 你懂的在线视频播放 | av一区在线 |