php 函数默认返回什么? [英] what does a php function return by default?

查看:20
本文介绍了php 函数默认返回什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我什么都不显式返回,那么 php 函数究竟返回什么?

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

function foo() {}

  1. 它是什么类型?

  1. What type is it?

它有什么价值?

我如何使用 === 完全测试它?

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

是否从 php4 更改为 php5?

Did this change from php4 to php5?

function foo() {}function foo() { return; 有区别吗?}

(我不是在问如何像 if (foo() !=0) ... 那样测试它)

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

推荐答案

  1. null
  2. null
  3. if(foo() === null)
  4. -
  5. 不.

您可以通过以下方式尝试:

You can try it out by doing:

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

这篇关于php 函数默认返回什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆