代码注释中的问题:
function find($id, Application_Model $guestbook)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return; // what is returned in functions like these?
}发布于 2013-03-27 00:18:31
PHP documentation会说“如果没有提供参数...将返回NULL。”所以这就是:
return;等同于:
return null;发布于 2013-03-27 00:18:32
它不会返回任何内容。也就是说,如果您尝试将该函数的输出赋给一个变量,那么该变量将为null。
function iDoNothing()
{
return;
}
$returnValue = iDoNothing();
// $returnValue is now null发布于 2013-03-27 00:19:31
不带参数的Return语句返回null。
你可以通过创建一个简短的php脚本来自己尝试一下:
<?php
echo emptyReturn();
function emptyReturn() {
return;
}
?>https://stackoverflow.com/questions/15641927
复制相似问题