gpt4 book ai didi

php - 奇怪的行为 : ( 0 == "string") is true| switch(0){} gives the first case 'case "a": '

转载 作者:可可西里 更新时间:2023-11-01 13:41:45 25 4
gpt4 key购买 nike

<分区>

如何this发生了什么?

var_dump(0=="some string"); // yields true, why?

switch(0) {
case "a":
echo "a"; // <-- we get here, why?
break;

case "b":
echo "b";
break;

default:
echo "def";
break;
}

据此

0=="some string"
0==(int)"some string"
0==0
true

这也是合乎逻辑的:

        0=="some string"
(string)0=="some string"
"0"=="some string"
false

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com