This website recently got a major rebuild; if you're missing something, let Lorna know.

    Tag: oop


  1. Video Course on Learnable: OOP PHP


    I'm delighted to announce that my new video course on Object-Oriented PHP is now available on Learnable! It's very much an introduction, aiming to cover WHY objects are so cool as well as how to declare and use one. The course is a mix of video (filmed in my kitchen …

    Read more

  2. 9 Magic Methods in PHP


    This post forms part of a series of articles about using PHP to do objected oriented programming, or OOP. They were originally published elsewhere but are no longer available at that location, so I'm reposting them here. Previously in the series was an introduction to OOP in PHP, in two parts

    The title is a bit of a red herring as PHP has more than 9 magic methods, but these will get you off to a good start using PHP's magic methods. It might be magic, but no wands are required!

    Read more

  3. A Little More OOP in PHP


    This post forms part of a series of articles about using PHP to do objected oriented programming, or OOP. They were originally published elsewhere but are no longer available at that location, so I'm reposting them here.

    This post follows an earlier entry introducing the basics OOP and what that looks like in PHP. This time around we'll look at some more advanced concepts and some more practical examples of building code, covering use of constructors and how to add access modifiers in to control how calling code can operate on your objects. We'll also show off how to create static methods and properties and, perhaps more importantly, illustrate applications of these features.

    Read more

  4. Introduction to PHP OOP


    This is the first in a series of articles about using PHP to do objected oriented programming, or OOP. They were originally published elsewhere but are no longer available at that location, so I'm reposting them here.

    Since the introduction of PHP 5 in 2004, PHP has had an object model worthy of that description and became a truly modern language for use on the web. Earlier PHP scripts would have been of the kind where, to quote from Alice's Adventures, you would "Begin at the beginning, and go on till you come to the end: then stop." Nowadays that very procedural approach is less common in PHP, so this article takes a look at some of the basic object oriented features available in the language and shows some examples of using them with code examples.

    Read more

  5. Upcoming PHP Courses


    image1Since becoming freelance 18 months ago, I've taught a number of courses at my excellent local tech training centre, NTI Leeds. Over the next few months we're running some one-day PHP courses (see my course dates page for more detail and the dates, all these are in Leeds although I'd like to run them elsewhere too), targeted at a particular area or set of skills. These are areas that I find myself delivering consultancy or training on frequently, or things I teach when I go places and realise these gaps exist in their knowledge. Does this match your experiences of "things I wish PHP developers knew - including me"?

    Read more

  6. ArrayAccess vs ArrayObject


    I help people qualify for Zend Certification and in the last few months I've had questions about both ArrayAccess and ArrayObject. This post is an attempt to illuminate both.

    Read more

  7. Using Gearman from PHP


    I've introduced Gearman into a project I'm working on, and since a few people have asked I thought I'd share my experiences. Basically, this application generates some PDFs from a variety of data sources, makes images, and emails it. Since the whole data processing, image handling, PDF generation process is fairly heavy, I'm putting the requests to generate these onto a gearman queue and having some workers process the jobs. The eventual aim is to bring up EC2 instances (or php-specific cloud hosting perhaps? Recommendations gratefully received!) to do this work but right now I have one worker and it's all on one server.

    Read more

  8. Declaring Static Methods in PHP


    I was confused recently to realise that I had accidentally called a static method in PHP dynamically from another part of my code; I expected PHP to output warnings when this is done. On closer inspection I discovered that:

    • Static functions can be called dynamically

    • Dynamic functions generate an E_STRICT error if called statically

    This made a lot more sense when I thought about it a bit more and wrote some toy code:

    Read more