php – 使用相同参数时爆炸是否相当于内爆?
作者:互联网
假设我有以下功能:
public function normalize($string) {
$substrings = explode(",", $string);
return implode(",", $substrings);
}
Will($string == normalize($string))总是如此?有什么特别的情况我应该考虑吗?
解决方法:
如果$string是一个字符串,是的.
否则可能会发生类型转换:
implode(",", explode(",", 0))
这将导致“0”因此$string!== normalize($string)但$string == normalize($string)仍然成立.
标签:php,explode,implode 来源: https://codeday.me/bug/20190622/1263269.html