Where you have your shopping cart php code also depends on how the php code is constructed. Personally I would suggest setting up your cart code as a php object which can be kept completely separate from any html code. You then simply instantiate an instance of the shopping cart php class and send items to it from your web page.
If you want to embed the cart php code into your web page code then how/where you do it depends on how you are getting the user to add an item to their cart. Post the hrml code prompting the user to add an item to their cart.