什么是PHP函数默认返回? [英] what does a php function return by default?
本文介绍了什么是PHP函数默认返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
function foo(){} $ b $如果我没有明确地返回任何东西, b
-
是什么类型的?
-
它的价值是什么?
li> -
从php4转换为php5吗?
-
函数是否有区别foo(){}
和function foo(){return; }
-
null -
null
-
if(foo()=== null)
- -
- 。
(我不是问如何像 if(foo()!= 0)...
)
解决方案
您可以通过以下方式尝试:
$ x = foo();
var_dump($ x);
If I return nothing explicitly, what does a php function exactly return?
function foo() {}
What type is it?
What value is it?
How do I test for it exactly with === ?
Did this change from php4 to php5?
Is there a difference between
function foo() {}
andfunction foo() { return; }
(I am not asking how to test it like if (foo() !=0) ...
)
解决方案
null
null
if(foo() === null)
- -
- Nope.
You can try it out by doing:
$x = foo();
var_dump($x);
这篇关于什么是PHP函数默认返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文