what does a php function return by default?

user89021 picture user89021 · Aug 2, 2009 · Viewed 17.9k times · Source

If I return nothing explicitly, what does a php function exactly return?

function foo() {}
  1. What type is it?

  2. What value is it?

  3. How do I test for it exactly with === ?

  4. Did this change from php4 to php5?

  5. Is there a difference between function foo() {} and function foo() { return; }

(I am not asking how to test it like if (foo() !=0) ...)

Answer

PatrikAkerstrand picture PatrikAkerstrand · Aug 2, 2009
  1. null
  2. null
  3. if(foo() === null)
  4. -
  5. Nope.

You can try it out by doing:

$x = foo();
var_dump($x);