我在「刪除」的情況下出現語法錯誤。我一直在試圖解決它,但我無法弄清楚。 誰能告訴我如何解決它由於在刪除時刪除時出現語法錯誤
的代碼是一個在線商店的購物車
switch($action)
{
case "add":
if (isset($_SESSION['cart'][$id]))
$_SESSION['cart'][$id]++;
else
$_SESSION['cart'][$id]=1;
break;
case "remove":
if (isset($_SESSION['cart'][$id]))
(
$_SESSION['cart'][$id]--; (ERROR HERE)
if ($_SESSION['cart'][$id]==0)
unset($_SESSION['cart'][$id]);
)
break;
case "empty":
unset($_SESSION['cart']);
break;
}
請不要提倡在身體周圍書寫沒有大括號的'if'語句。 – Barmar
@Barmar:謝謝你的提示!你可以讓我知道如果我不使用支架單線聲明後有什麼傷害? –
http://stackoverflow.com/questions/12193170/whats-the-purpose-of-using-for-a-single-line – Barmar