make switch use === comparison not == comparison In PHP

后端 未结 15 2201
一向
一向 2020-11-28 07:09

Is there anyway to make it so that the following code still uses a switch and returns b not a? Thanks!

$var = 0;
switch($var) {
            


        
15条回答
  •  天涯浪人
    2020-11-28 07:35

    Switch statement in php does loose comparisons only (==) see http://www.php.net/manual/en/control-structures.switch.php

    Use if/elseif/else if you need strict comparisons.

提交回复
热议问题