How to Store and Retrieve Binary Data Using PHP and MySQL

It isn’t too long into your web development career before you get to a point where you can store and retrieve plain-text data in your sleep. Being strong in this area is important, as plain text is the most commonly stored data format. However, there are situations in which storing and retrieving binary data is useful, too. In this article, Larry Ullman explains exactly how you can do that using PHP and MySQL, and why you would want to.

Databases are simply warehouses for information: a reliable place to put, and later fetch, data. Most of the time, the stored information will be in a plain-text format. Just the characters on your keyboard are sufficient to represent:

  • Numbers
  • Strings (i.e., characters and longer text)
  • Dates and times

Continue reading

Creating a Shopping Cart Class Using Object-Oriented Programming in PHP

E-commerce is clearly one of the most prominent uses of PHP today, a trend that’s certain to continue. An e-commerce site can be created in many ways, whether that means using a third-party application like osCommerce or writing one from scratch in classic, procedural PHP code. In this article, web developer Larry Ullman presents the class structure you could use to create the core of a shopping cart application using object-oriented programming.

One of the many benefits of object-oriented programming (OOP) is reusability: A well-defined class can easily be applied to different projects, even by different developers. And thanks to some of the more recent additions to PHP, such as interfaces and the Standard PHP Library (SPL), top-quality classes can be created with a wealth of flexibility and power.

Continue reading