[英]Strcmp trouble. Strings are no equal
why its echo 1
?为什么它的 echo
1
? this 2 strings are the same!这两个字符串是一样的!
strcmp()
should be 0
! strcmp()
应该是0
! What's wrong?怎么了? Can someone tell me why this two strings are NOT equal?
有人能告诉我为什么这两个字符串不相等吗?
if(!strcmp("+7 (921) 111-11-11", "+7 (921) 111-11-11"))
echo "1";
strcmp()
does evaluate to 0 in this case - But this leads to it being type juggled to false, and then to !false, so the original statement runs.在这种情况下,
strcmp()
计算结果为 0 - 但这会导致它被类型转换为 false,然后变为 !false,因此原始语句会运行。 Change it to this:改成这样:
if (strcmp("+7 (921) 111-11-11", "+7 (921) 111-11-11") !== 0)
echo 1; // Strings are not equal
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.