【问题标题】:PHP error "Strict Standards: Only variables should be passed by reference"PHP 错误“严格标准:只能通过引用传递变量”
【发布时间】:2017-07-24 23:13:40
【问题描述】:

使用 PHP 创建图片库时收到此错误; “严格的标准:只有变量应该在第 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;
}

【问题讨论】:

  • 这很难说,因为你发布的内容甚至没有 25 行,第 25 行在哪里?
  • @AhmedMasud 真的很抱歉,我忘记了在获取 sn-p 时更改值。现已更新!

标签: php variables standards strict


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-25
    • 2013-05-21
    • 1970-01-01
    • 2012-04-08
    • 2015-02-02
    • 2017-07-08
    相关资源
    最近更新 更多