我试图从函数中取出 $keysList 数组,但似乎在某个地方出错了。我收到错误:
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';
}
?>