PHP 错误 "Strict Standards: Only variables should be passed by reference"

PHP error "Strict Standards: Only variables should be passed by reference"

使用 PHP 创建图片库时收到此错误; "Strict Standards: Only variables should be passed by reference in (filename) on line 5"

有谁知道如何修复或隐藏此错误?由于实际的画廊可以很好地处理错误。谢谢!

代码如下:

public function getImages($extensions = array('jpg', 'png')) {
    $images = $this->getDirectory($this->path);

        foreach($images as $index => $image) {
            $extension = strtolower(end(explode('.', $image)));
            if(!in_array($extension, $extensions)) {
                unset($images[$index]);
            } else {
                $images[$index] = array(
                    'full' => $this->path . '/' . $image,
                    'thumb' => $this->path . '/thumbs/' . $image,
                    );
            }
        }

    return (count($images)) ? $images : false;
}

end() 需要一个实际的数组,因为它会将指针移动到末尾。

end(explode('.', $image)) 将不起作用。

相反,您可以尝试例如: $extension = pathinfo($image, PATHINFO_EXTENSION);