【问题标题】:'Strict Standards: Only variables should be passed by reference' error [duplicate]“严格的标准:只有变量应该通过引用传递”错误[重复]
【发布时间】:2015-04-28 01:40:43
【问题描述】:

我正在一个网站上实现 phpmobilizer。我创建了一个子域“m”,其中包含一个包含以下代码的文件(这只是一个部分):

function __construct($url){
    $this->url = $url;
    $this->server = preg_replace('/^m\./', '', $_SERVER['SERVER_NAME']);
    $this->ext = strtolower(end(explode('.', $this->url)));
    $this->patterns = array();
    $this->replacements = array();
    $this->cookieDomain = $this->__getCookieDomain();
}

我得到的错误在第 15 行:

$this->ext = strtolower(end(explode('.', $this->url)));

严格的标准:只有变量应该在 website.com/m/phpmobilizer.class.php 第 15 行通过引用传递

这是我在 head 部分中用来将移动用户重定向到“m”子域的代码。我已经使用 Google 的移动友好测试对移动子域进行了测试,它运行正常。

【问题讨论】:

    标签: php


    【解决方案1】:

    错误是由使用 'end()' 引起的。数组通过引用传递给 end()。

    尝试拆分代码,例如

    $urlParts = explode('.', $this->url);
    $this->ext = strtolower(end($urlParts));
    

    参考: http://php.net/manual/en/function.end.php

    【讨论】:

    • 感谢我的朋友成功了!!
    猜你喜欢
    • 2014-11-01
    • 2015-05-27
    • 2016-10-05
    • 2014-08-17
    • 2016-10-11
    • 2018-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多