购物车2数据处理session.txt $gname,'gnum'=1];print_r($_SESSION);}else{//判断是否有该商品if(array_key_exists($gid, $_SESSION['cart'])){$_SESSION['cart'][$gid]['gnum']+=1;}else{//没有直接添加 $_SESSION['cart'][$gid]=['gnam
$gname, 'gnum'=>1 ]; print_r($_SESSION); }else{ //判断是否有该商品 if(array_key_exists($gid, $_SESSION['cart'])){ $_SESSION['cart'][$gid]['gnum']+=1; }else{ //没有直接添加 $_SESSION['cart'][$gid]=[ 'gname'=>$gname, 'gnum'=>1 ]; } } echo ""; print_r($_SESSION['cart']); echo "点击购买<>"; ?>