php list() 貌似不支持k=>v呢?
来源:4-4 异常处理-错误字典、TryCatch的集中捕获

慕标3075454
2017-08-09
测试代码:
$a= null;
$b= null;
list($a,$b) = array("1","2");
返回:
$a=1;
$b=2;
测试代码:
$a= null;
$b= null;
list($a,$b) = array("errno"=>"1002","errmsg"=>"123");
返回:
$a=null;
$b=null;
报错信息:
Notice: Undefined offset
写回答
2回答
-
hong泓零食店
2017-09-21
我也遇到这个问题。知道有没有更优的解决方案
012018-02-17 -
慕标3075454
提问者
2017-08-09
我的php版本是7.0.12
有可能是php版本问题。
解决办法:
使用:array_values()
返回数组中所有的值。
list(self::$errno,self::$errmsg) = array_values(Err_Map::get(1005));
00
相似问题