当你给一个需要字符串的PHP函数赋予NULL时会发生什么? [关闭]

For example to: preg_match or when you use concatenation?

Answer to comments:

I can test for preg_match or concatenation results, yes.

But there is a difference between:

PHP function with the signature: int f(string $parameter)

  • Will PHP convert the NULL to empty string before the f function gets it, or
  • Will the f function get NULL even if signature expects string, so the function may throw exceptions or behave not as it would received an empty string.

(I can't test this, because I can't write string type for a parameter at function signature.)

It depends on the function you used for. Some may support null as parameter, some not. Some may throw notice, but dont forget that null may be converted to "" (empty string)