从PHP 7.0升级到PHP 7.1.致命错误:只有变量可以通过引用传递-使用数组的$string get_param命



我们是一家网球和壁球俱乐部,经营nBills,这是一个不再积极支持的发票系统。我在从PHP5升级到7时对它进行了护理,但在进一步升级到PHP7.1时,应用程序没有加载,我收到了以下致命错误消息:

Fatal error: Only variables can be passed by reference in /xxxxxxxx/public_html/administrator/components/com_nbill/classes/base/data_mapper.php on line 98.

我知道哪里出了问题,但我无法解决,这超出了我对PHP的有限了解。删除代码部分可以使应用程序正常工作,然后它似乎可以正常工作。

错误的陈述是:

$string = nbf_common::get_param(array($key=>$value), $key, '', false, (string)@$col[0]->encode_html != "false", (string)@$col[0]->allow_html == "true", (string)@$col[0]->allow_html == "true");

代码的完整部分显示:

* Return an appropriate string to use for the value in an SQL statement
(escaped, or intval'd as appropriate for the data type, based on the XML
schema file, if found, or just treated as a string [and escaped] otherwise)
* @param string $key Column name
* @param mixed $value Literal value
*/
protected function getValueSqlString($key, $value)
{
$string = "";
if ($this->schema)
{
$col = $schema->xpath("columns/column[@name='$key']");
switch (@$col->type)
{
case "int":
case "tinyint":
case "smallint":
case "mediumint":
case "bigint":
case "integer":
case "long":
$string = strval(intval($value));
break;
default:
$string = nbf_common::get_param(array($key=>$value),
$key, '', false, (string)@$col[0]->encode_html != "false", 
(string)@$col[0]->allow_html == "true", 
(string)@$col[0]->allow_html == "true");
break;
}
}
if (!$string) {
$string = "'" . $this->db->getEscaped($value) . "'";
}
return $string;
}
/**

收到任何最感激的帮助。请注意,我们正在积极寻求替代发票系统,并正在试用CBSubs。

CBSheen

<?php
$array = array($key=>$value);
$string = nbf_common::get_param(strtolower(array_pop($array)), $key, '', false, (string)@$col[0]->encode_html != "false", (string)@$col[0]->allow_html == "true", (string)@$col[0]->allow_html == "true");

请尝试上面的代码。我不是joomla专家,但根据您的错误,我认为问题是当您试图在get_param函数内传递数组时。

nbf_common::get_param()

查找此函数,查看哪些参数是通过引用传递的,然后检查实际作为该参数传递的值是否可以作为引用传递。这可能是pr1nc3所说的。

最新更新