[英]PHP: What variable type does 'return;' return?
以下面的代碼為例:
<?php
function testing(){
echo 'testing';
return;
}
?>
根據上面的代碼,“返回”是哪種類型的數據/變量; 報表返回?
返回null
。 看這個演示
<?php
function test() {
return;
}
var_dump(test()); // NULL
您的代碼將返回NULL
返回引用的函數可能會返回NULL值。 這與以下事實不一致:通過引用傳遞的函數參數不能以NULL傳遞(或實際上不是變量的任何事物)。
即
<?php
function &testRet()
{
return NULL;
}
if (testRet() === NULL)
{
echo "NULL";
}
?>
解析良好並返回NULL
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.