久久久久久久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>
                        • 主站蜘蛛池模板: 三级av在线 | 天堂精品视频 | 精品自拍视频 | 久久久资源 | 国产午夜在线观看 | 日韩福利在线观看 | 日韩在线观看中文字幕 | 国产成人免费视频网站视频社区 | 欧美日韩国产一区二区三区 | 亚洲精品久久久一区二区三区 | 国产精品入口久久 | 夜夜精品浪潮av一区二区三区 | 亚洲视频欧美视频 | 天堂中文字幕av | 久久久久99 | 国产综合网址 | 欧美在线观看一区 | 国产午夜精品理论片a大结局 | 成年人免费网站 | 91高清在线观看 | 久久国产一区二区三区 | 久久久久久国模大尺度人体 | 国产精品一区二区三区久久 | 亚洲网在线 | 午夜三级视频 | 成人欧美一区二区三区在线播放 | 欧美日本久久 | 毛片在线看片 | 久久久久久久国产 | 国产成人综合在线 | 国产精品国产三级国产aⅴ中文 | 午夜精品久久 | 精品av | 毛片在线看片 | 成人av电影免费在线观看 | 国产7777 | 欧美国产一区二区三区 | 国产欧美一区二区久久性色99 | 国产第一页在线播放 | 亚洲电影中文字幕 | 亚洲色欧美另类 |