Archive for the ‘PHP’ Category

Getting Called Class Name in Static Functions

I posted a few months ago about using static methods in WordPress plugins. I’ve used that method myself for the last few months, and I’ve really grown to love the style of code that this technique produces. One part, however, was a source of some pain: Inheritance

[More]

PHP Global Object Code Completion

Any IDE worth using provides code completion suggestions as you type. For example, this is what Netbeans suggests when you type “wp_” inside a WordPress project. The problem with dynamically typed languages like PHP is that it can be difficult for the IDE to provide intelligent suggestions for variables that have been defined in the global scope. It’s possible to help your IDE be a little smarter by providing it with hints about the types of objects.

[More]

Converting PHP Associative Arrays to Variables

EDIT: Nick Ohrn pointed out that a function exists for doing this automatically. The following post is still a valid look at how this could be implemented if the functionality didn’t already exist, but it is better to use extract because it is likely more efficient.

Associative arrays are one of my favorite PHP features. They’re simple to use and easy to understand. Sometimes though, being able to reference the values of associative arrays with variables can be more convenient. Today I’m going to share a simple way to convert an associative array to variables.

[More]