【发布时间】:2019-03-25 08:25:50
【问题描述】:
如何解决此错误:
警告:isset 中的偏移类型非法或 F:\xampp\htdocs\digikalamvc\core\model.php 第 140 行为空
致命错误:未捕获错误:F:\xampp\htdocs\digikalamvc\models\model_showcart4.php:90 中不支持的操作数类型:90 堆栈跟踪:#0 F:\xampp\htdocs\digikalamvc\controllers\showcart4.php(31 ): model_showcart4->saveOrder(Array) #1 F:\xampp\htdocs\digikalamvc\core\app.php(34): Showcart4->saveorder() #2 F:\xampp\htdocs\digikalamvc\index.php( 7): App->__construct() #3 {main} 在第 90 行的 F:\xampp\htdocs\digikalamvc\models\model_showcart4.php 中抛出
model.php 第 140 行的代码:(if (isset($_SESSION[$name])) {)
public static function sessionGet($name) {
if (isset($_SESSION[$name])) {
return $_SESSION[$name];
} else {
return false;
}
}
model_showcart4.php 第 90 行中的代码:
$priceTotal =$basketPrice-$basketDiscount+$postprice;
代码model_showcart4:
$basket = $basketInfo[0];
$basket = serialize($basket);
$basketPrice = $basketInfo[1];
$basketDiscount = $basketInfo[2];
$postprice = $this->calculatePostPrice($addressInfo['city']);
$postType = self::sessionGet(['postType']);
if ($postType == 1) {
$postprice = $postprice['pishtaz'];
} elseif ($postType == 2) {
$postprice = $postprice['sefareshi'];
}
$priceTotal =$basketPrice-$basketDiscount+$postprice;
代码 showcart4.php 在第 31 行:
function saveorder() {
$this->model->saveOrder($_POST);
}
【问题讨论】:
-
您将数组作为键传递给 isset 中的数组。
$postType = self::sessionGet(['postType']);参数是数组。但是数组不能是其他数组中的键