Is an explosive equivalent implanted using the same parameter?

Let's say I have the following function:

public function normalize($string) {
  $substrings = explode(",", $string);
  return implode(",", $substrings);
}

Will it ($string == normalize($string))always be true? Is there any special case that I should consider?

+4
source share
1 answer

If $ string is a string, yes.

Otherwise, a type conversion may occur:

implode(",", explode(",", 0))

This will result in "0" in this way $string !== normalize($string), but $string == normalize($string)is still persistent.

+4
source

Source: https://habr.com/ru/post/1692062/


All Articles