PHP這個語句是什麼意思呢解決思路

來源:互聯網
上載者:User
PHP這個語句是什麼意思呢
!$status && $status = $pm['msgtoid'] && $pm['new'];

PHP這個語句是什麼意思呢

------解決方案--------------------
!$status && $status = $pm['msgtoid'] && $pm['new'];

如果 !$status == 1 (即 $status == 0)
並且 $status = $pm['msgtoid'] (賦值後的$status不為0)
並且 $pm['new']不為0

那麼。。。。。
------解決方案--------------------
!$status && $status = $pm['msgtoid'] && $pm['new'];
!$status返回一個BOOL值,表示非$status
非$status為真的時候才會執行後面的賦值操作。
$status = $pm['msgtoid'] && $pm['new'];
$pm['msgtoid'] && $pm['new']返回的也是BOOL值。
只有當$pm['msgtoid']和$pm['new']都不為空白,不等於0,不等於false,不為NULL,時才返回true.
------解決方案--------------------
!$status && $status = $pm['msgtoid'] && $pm['new'];
運算順序:
(!$status) && ($status = $pm['msgtoid'] && $pm['new']);
等於 (!$status) && $pm['msgtoid'] && $pm['new'];
這樣寫是將$pm['msgtoid'] && $pm['new']的運算結果在賦值給$status, 可能是為了下面程式的使用,要麼就是蛋疼
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.