How to get shopping cart items and totals in magento

Here, We will explain How to get shopping cart items and totals in magento?

The code for getting all items in shopping cart:

The code for getting total items and quantity of shopping cart:

The code for getting subtotal and grand total price of shopping cart: