Singleton Pattern In PHP… How Can I Save State Between Requests
问题 With the use of static variables and the singleton pattern, I thought that it would be easy enough to create a simple shopping cart that remembered what items where in the cart when another page was loaded. I am having a problem of the shopping cart not remembering what was already in it when the page is refreshed. Is there a problem with my code below or should I just use globals or a mysql database. What is the best way to go about storing state.. <?php //create a singleton class class