ITT #10: Understanding OOP

NOTE: This comment by Cal Evans pointed out an oversight on my part regarding naming conventions for classes. To avoid conflicting with other classes, names should be distinctive, and as such, I changed the name of the example class from "date" to "Ennui_Date".

Recently, I've fielded a handful of questions concerning object-oriented PHP. What is it? How does it work? Why should we care?

I had similar questions when I first started looking at OOP. I mean, why the hell would I want to switch from the easy-to-understand procedural method?

Classes and objects might look confusing and difficult to manage at first, but they actually significantly improve the organization and readability of your code if used properly.

A Practical Example

Let's say, for instance, that we need to be... read more

ITT #7: Dynamically Change Width and Height in HTML Markup

A Quick Note from the Guest Author Hello everyone, I'm Brenley Dueck or better known as Brenelz. I currently run my own business called Brenelz Web Solutions which focuses primary on web design in winnipeg. The web technologies I most specialize in are CSS, jQuery, AJAX, PHP, and the MySQL database. Please make sure to visit my web design blog and follow me on twitter.

Defining the Problem

In a recent project I was working on we had to allow the client to embed videos within the site. This had to be done using an easy-to-use customized CMS. The thought is that they can take the embed code right off the YouTube site and save it to the DB for use throughout the site.



YouTube's... read more

ITT #6: PHP Arrays as Return Values

In this installment of Instant Tip Tuesday, we're going to talk about arrays in PHP. According to the PHP manual, an array is "an ordered map that associates values to keys." The benefit of using arrays is that we can pack a ton of data into one variable, which means we can pass that data back through a function.

What's So Cool About Passing Arrays?

I use arrays as return values to keep my processing of data separate from the formatting of said data. This is done in an effort to make code maintenance easier in the future. For example, look at the following code:

<html> <body> <?php require_once '_db/mysql.php'; // Connect to the database $data = getDataFromDB("blog", 5); // returns latest 5 blog entries ... read more

  • «
  • 1
  • »