检查这段代码:
$last = end($p = explode('/', $someString));
收到此通知:
Only variables should be passed by reference
我真的很困惑,因为 $p
是一个变量。
最佳答案
end()
需要一个变量,而不是一个引用。在你的例子中 $p = explode('/', $someString)
不是一个变量,它是一个赋值。作为documentation说:
This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.
你应该这样做:
$p = explode('/', $someString);
$last = end($p);
关于php - 为什么我会收到 "Only variables should be passed by reference"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20776017/