Skip to content
Archive of posts filed under the PHP category.

Beginners’ Corner: Variable Function Parameters

Sometimes when defining a function in PHP, you find that there may be cases where you do not want to specify all the possible parameters when calling it. This could be because you want it to use a default value, or that in certain cases it does not logically apply. If you find yourself in [...]

Book List App: One Query to Rule Them All

I got side-tracked from working on this project for awhile, but I am trying to get back to it now.
One thing I needed to address was that for many of the database tables I would have situations where a user supplies some data, and if it already exists in the table then I just need [...]

Memory Usage in PHP GD Image Functions

When working with the PHP GD Image functions, memory usage can become a serious issue. Where PHP developers often stumble is in not realizing that the various imagecreate*() functions create a bitmap in memory with data for each and every pixel. Therefore a source JPEG file that is only a few tens of kilobytes in [...]

Beginners’ Corner: Learning Object-Oriented PHP

I often see PHP newbies (and even not-so-newbies) who are confused by the world of object-oriented programming (OOP). At least part of this confusion results from the vast majority of introductory books and tutorials for PHP beginning by teaching procedural programming techniques, treating OOP as an “advanced” subject with a chapter or two at the [...]

Implementing a Database-based Session-handler

While I’ve been using the database session data handler in the CodeIgniter framework for some time, upon reading this thread at PHPBuilder forums I decided it was time to write my own. In part I just wanted to gain a more thorough understanding of the process, and I also figured I could use it some [...]

Book List App: Using Auto-Suggest with CodeIgniter

I had a couple fields on the form for adding authors/books to the DB for which I wanted to use an “auto-suggest” feature via JavaScript; one of those things where after you start typing it pops up a list of matching choices from which you can select the one you want. After trying several different [...]

Book List Project: Using the “Template” Pattern

As part of my Book List project I am making use of the Template design pattern for my CodeIgniter database table models. The idea is that an abstract class contains the common processing needed by each class that will extend it, and it will have some number of abstract methods which essentially force each child [...]