I m试图从功能中获取阵列数据,但保留错误: 无定义可言:地位。 如何纠正这种情况的想法?
<?php
$state = New York ;
function state_values($state){
switch ($state) {
case New York :
echo "State is $state";
$status = array("abbr" => "NY", "code" => "03");
return $status;
break;
case California :
echo "State is $state";
$status = array("abbr" => "CA", "code" => "06");
return $status;
break;
case Washington :
echo "State is $state";
$status = array("abbr" => "WA", "code" => "05");
return $status;
break;
}
}
# Call the function
state_values($state);
echo $status[ abbr ];
echo $status[ code ];
?>