我得到一个未定义的:指数minicart错误中隔离会话变量
我有一个会话变量['cart_array']
其存储在多个阵列项目,我确定他们像
// If the cart session variable is not set or cart array is empty
if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
// RUN IF THE CART IS EMPTY OR NOT SET
$_SESSION["cart_array"]["minicart"] = array(0 => array("item_id" => $pid, "quantity" => 1));
什么是预防的最佳方法这个?
有时你使用'$ _SESSION [“minicart”]'有时''_SESSION [“cart_array”] [“minicart”]'并且你写了'mini_cart' ...你可能需要对此进行排序。在您创建的代码中没有任何地方设置了会话变量。 – Bun
@Bun意外地删除了一个'[“minicart”]',但我现在把它放在问题中... – Amy