严格的标准:只有变量应该通过引用传递 PHP 购物车

Strict Standards: Only variables should be passed by reference PHP Shopping Cart

我目前正在创建 PHP 购物车,但一直卡在错误 "Strict Standards: Only variables should be passed by reference PHP Shopping Cart" 中。我研究了这个错误,找到了许多不同的解释来解释为什么会发生这种情况。我似乎无法解决这个问题。任何帮助将非常感激。请在下面查看我的代码。

  $img=mysql_real_escape_string(end(explode('/',$_POST['img'])));

你需要分解你的代码,而不是一次完成,就像这样:

$imgArr = explode('/',$_POST['img']);
$img = end($imgArr);
$imgEscaped = mysql_real_escape_string($img);

原因是 end() 期望 变量 通过引用传递,因此您需要先将 explode() 分配给中间变量。