この問題に関する多くの投稿があることを理解しています。多くの投稿を見てきましたが、何らかの理由で答えを見つけることができます!
どんな助けでも大歓迎です。PHP初心者なので間違っていたらごめんなさい。
配列を使用して基本的なバスケット システムを作成しようとしています。行で undefined index というエラーが発生し続けます$_SESSION['cart'][$app_ID]++;
面白いのは、すべてが正しく機能していることです! エラー報告をオフにするだけでなく、エラーを解決したい。
if(isset($_GET['id'])){
$app_ID = $_GET['id']; //the item id from the URL
$action = $_GET['action']; //the action from the URL
$total = 0;
if (isset($app_ID)){
switch($action) {
case "add":
$_SESSION['cart'][$app_ID]++;
break;
case "remove":
$_SESSION['cart'][$app_ID]--;
if($_SESSION['cart'][$app_ID] == 0) unset($_SESSION['cart'][$app_ID]);
break;
case "empty":
unset($_SESSION['cart']); //unset the whole cart, i.e. empty the cart.
break;
みんなありがとう。