如何确定函数是否不返回任何内容? [英] How to determine if function doesn't return anything?

查看:43
本文介绍了如何确定函数是否不返回任何内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以在PHP中使用Reflection或其他方式?

Is there a way to do this in PHP, using Reflection or something?

function a{
  return null;
}

function b{

}


$a = a(); // null
$b = b(); // null :(

推荐答案

如果您未明确返回某些内容,则默认情况下函数将返回 null .这就是函数在PHP中的工作方式,无法找出函数是否具有返回值.

If you do not explicitly return something then functions will return null by default. That is just how functions work in PHP, and there is no way of finding out if the function has a return value.

但这应该不是问题.如果函数返回null,通常意味着什么也没做,或者什么也没找到,等等.

This should not be a problem, though. If a function returns null it usually means that nothing was done, or that nothing was found, etc.

这篇关于如何确定函数是否不返回任何内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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