使用相同参数时爆炸是否等同于内爆?(Is explode equivalent to implode when using the same parameter?)
假设我有以下功能:
public function normalize($string) { $substrings = explode(",", $string); return implode(",", $substrings); }Will ($string == normalize($string))总是如此? 有什么特别的情况我应该考虑吗?
Let's say I have the following function:
public function normalize($string) { $substrings = explode(",", $string); return implode(",", $substrings); }Will ($string == normalize($string)) always be true? is there any special case I should consider?
最满意答案
如果$ string是一个字符串,是的。
否则可能会发生类型转换:
implode(",", explode(",", 0))这将导致“0”因此$string !== normalize($string)但$string == normalize($string)仍然成立。
If $string is a string, yes.
Otherwise type conversion may occur:
implode(",", explode(",", 0))This will result in "0" thus $string !== normalize($string) but $string == normalize($string) still holds true.
更多推荐
发布评论