Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从类中的公共函数中检索值到foreach.
foreach
$class->function()正在传递一个数组,我想扫描每个值。
$class->function()
foreach($class->function() as $key => $index) { $class->function()[$key];
奇怪的是,这段代码localhost运行正常,但在我的服务器上在线给出了这个错误:
localhost
解析错误:语法错误,意外 '[',期待 ',' 或 ';'
将函数的结果分配给某个变量:
$result = $class->function(); foreach($result as $key => $index) { echo $result[$key]; }
但是$result[$key]等于$indexFYI;
$result[$key]
$index
这种直接来自函数调用的访问值从PHP 5.4.
PHP 5.4