This is about the shopping cart class where PHP implements the codeigniter of imitation writing. Share to everyone for your reference. Specific as follows:
Shopping Cart Basic Features:
1) Add items to your shopping cart
2) remove items from your shopping cart
3) Update Shopping cart item Information "+1/-1"
4) Statistics on shopping cart items
1. Total Items
2. Total Quantity
3. Total Amount
5) Statistics on the quantity and amount of items in the shopping item
6) Empty Cart
First download the PHP codeigniter that we need to use for this lesson: http://www.php.cn/xiazai/leiku/337
After the download, find the PHP class files we need, unzip to our local directory, create a new PHP file!
Once this is done, we will invoke this class in the new PHP file, and instantiate the class:
<?phprequire_once (' cart1.php ');//Introduction of class file $cart = new cart ();//instantiation $cart->insert ($items); Var_dump ($cart->contents ()); $cart->update ($arr); Var_dump ($cart->contents ());? >
The results of the operation are as follows: