我试图从函数中获取$ keysList数组,但似乎在某处出错。我得到错误:从php函数内部返回数组无效
Passed Notice: Uninitialized string offset: 2 in C:\web\apache\htdocs\dev\case2.php on line 40 Notice: Uninitialized string offset: 1 in C:\web\apache\htdocs\dev\case2.php on line 40 Notice: Uninitialized string offset: 0 in C:\web\apache\htdocs\dev\case2.php on line 40 Output = a , a and a .
如何得到它正确的?
<?php
$catHandle = "addCat";
function validCatKeys($catHandle,$keysList)
{
switch($catHandle){
case "addCat":
$listCountryCode = 'US';
$listUserName = 'Norman';
$listUserId = '1';
$keysList = array($listCountryCode,$listUserName,$listUserId);
return true;
break;
case "addSubCat":
break;
case "addElm":
break;
default:
return false;
}
}
if(validCatKeys($catHandle,$keysList = ''))
{
echo 'Passed';
list($a, $b, $c) = $keysList;
echo "Output = a $a, a $b and a $c.";
}else{echo 'Failed';
}
?>
重复问题? http://stackoverflow.com/questions/5692568/php-function-return-array – 2013-05-01 08:20:26
@Al。但我的情况完全不同。 – Norman 2013-05-01 08:22:12
@norman尝试回答演示其工作。 – 2013-05-01 08:26:41