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

后端 未结 15 2157
一向
一向 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条回答
  •  Happy的楠姐
    2020-11-28 07:14

    If you want to test both value and type of your variable, then build a new string variable containing both informations and compare it with your different scenarios (by concatenation) it should work for your case if you implement all possible types (according to gettype() documentation), example :

    
    

提交回复
热议问题