<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 賦值運算符 基本上的賦值運算符是“=”。一開始可能會認為它是“等于”,其實不是的。他實際上意味著把右邊表達式的值賦給左邊的運算數。 賦值運算表達式的值也就是所賦的值。也就是說,“$a = 3”的值是3。這樣就可以做一些小技巧: ``` <?php $a = ($b = 4) + 5; // $a 現在成了 9 ,而$b 成了4. ?> ``` 在基本賦值運算符之外,還有適合于所有[二元算術](http://php.net/manual/zh/language.operators.php),數組集合和字符串運算符的“組合運算符”,這樣可以在一個表達式中使用它的值并把表達式的結果賦給它,例如: ``` <?php $a = 3; $a += 5; // set $a to 8,as if we had said: $a = $a + 5; $b = "Hello"; $b .= "There!"; // sets $b to "Hello There!", just like $b = $b . "There!"; ?> ``` 注意賦值運算將原變量的值拷貝到新變量中(傳值賦值),所以改變其中一個并不影響另一個。這也適合于在密集循環中拷貝一些值例如大數組。 在PHP中普通的傳值賦值行為有個例外就是碰到對象[object](http://php.net/manual/zh/language.types.object.php)使用了 時,在PHP5中是以引用賦值的,除非明確 使用了[clone](http://php.net/manual/zh/language.oop5.cloning.php) 關鍵字來拷貝。 ## 引用賦值 PHP只是引用賦值,使用“$var = &$othervar;”語法。引用賦值意味著兩個變量指向了同一個數據,沒有拷貝任何東西。 **Example #1 引用賦值** ``` <?php $a = 3; $b = &$a; // $b 是 $a 的引用 print "$a\n"; // 輸出3 print "$b\n"; // 輸出3 $a = 4; // 修改 $a print "$a\n"; // 輸出 4 print "$b\n" // 也輸出 4,因為$b 是 $a 的引用,因此也被改變 ?> ``` 自PHP5起,new運算符自動返回一個引用,因此再對new的結果進行引用賦值在PHP5.3以及以后版本中會發出一個條E_DEPRECATED錯誤信息,在之前版本會發出一條E_STRICT錯誤信息。 例如以下代碼將產生警告: ``` <?php class?C?{} /*?The?following?line?generates?the?following?error?message: ?*?Deprecated:?Assigning?the?return?value?of?new?by?reference?is?deprecated?in... ?*/ $o?=?&new?C; ?> ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看