为什么此代码的工作:奇怪的行为返回由函数
$row = $stmt->fetch();
$result = array("status"=>"0", "uid"=>($row["id"]));
而这一次没有:
$result = array("status"=>"0", "uid"=>(($stmt->fetch())["id"]));
为什么此代码的工作:奇怪的行为返回由函数
$row = $stmt->fetch();
$result = array("status"=>"0", "uid"=>($row["id"]));
而这一次没有:
$result = array("status"=>"0", "uid"=>(($stmt->fetch())["id"]));
由于PHP 5.4有可能你做了什么。
getSomeArray()[$someKey]
参考:http://php.net/manual/en/language.types.array.php#example-88
此前PHP 5.3,你需要使用一个临时变量。
酷,我不知道他们补充说,在PHP 5.4。 –
@MattBrowne我知道,它非常有用 – imulsion
为什么人们一直downvoting呢?在PHP 5.3或更低版本中,临时变量确实是实现此目的的唯一方法。 –
很抱歉的重复,并感谢您的回答。 –
@ValentinSolina没问题。感谢15代表接受;) – imulsion