您好,欢迎访问一九零五行业门户网

php购物车 php购物车实现代码

shopcar.php
复制代码 代码如下:
productlist[$i]['name']==$product['name'])
return $i;
}
return -1;
}
//添加到购物车
public function add($product)
{
$i=$this->checkproduct($product);
if($i==-1)
array_push($this->productlist,$product);
else
$this->productlist[$i]['num']+=$product['num'];
}
//删除
public function delete($product)
{
$i=$this->checkproduct($product);
if($i!=-1)
array_splice($this->productlist,$i,1);
}
//返回所有的商品的信息
public function show()
{
return $this->productlist;
}
}
productlist.html
复制代码 代码如下:
商品编号 商品名称 价格 数量 购买
0 商品1 1
商品2 2
商品3 1
商品4 1
以上就介绍了php购物车 php购物车实现代码,包括了php购物车方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息