Home

Regex - match anything but a string

22/09/2010 17:26 Paul Norman 0 comments

Regular expressions are something of a black art for programmers, and many get by without ever really learning them properly. Sure, most people will be able to use them to some level, but if you don't use them for complex tasks in your day to day work you'll never really need their advanced functionality. I sadly fell into this camp the other day when I needed to say 'match everything except a whole word.' This sounds easy doesn't it, but actually it's less obvious than it seems...... read article

PHP Spinner Updated - Spin articles for SEO

22/09/2010 15:53 Paul Norman 0 comments

Quite a while ago I wrote a post on spinning text using PHP to create lots of fresh content from one single block of marked up text. I actually had use for a nested version of this spinning code the other day so set about creating a more efficient version of my previous nested spin code and packed it up in a class wrapper so it would choose whether to use the nested spinner or the flat version dynamically.... read article

Hierarchical Class Loading With Namespaces

27/01/2010 20:30 Paul Norman 0 comments

A challenge often encountered when developing in PHP is the ability to instantiate a class from the highest point in a folder hierarchy where that class exists, but fall down the hierarchy when it is missing. This can be done using a factory class and reflection, but is not the most obvious thing in the world!... read article

Rounding Corners on Websites

09/07/2009 15:49 Paul Norman 0 comments

There are many many ways to do this floating around, here is just another that I have used in the past. It uses one large image file (which will be cached after the first use) and focuses on simplification of HTML markup.... read article

Optimising Your Site's CSS, JavaScript, Images and Server Settings

09/07/2009 15:32 Paul Norman 0 comments

The speed at which a site loads these days is becoming less of an issue, but still I occasionally visit a site where I think "wow, that's slow!" and look at the requests it is making in Firebug to see what on earth is going on. Often it's a simple case of loads and loads of individual requests being made for js files, css files and (large) images. We can do something about this!... read article

Using Google to Calculate Driving Distance / Time in PHP

09/07/2009 14:40 Paul Norman 0 comments

A common problem for programmers is to calculate the straight line distance between two points given coordinates (lon / lat or easting / northing) and is trivial to solve. A less simple task is calculating the road distance between two addresses / postcodes / sets of coordinates. But, as usual, Google can do this with ease and while it does not allow this functionality for every country in it's API it is very simple to scrape the required information from their html service that they provide to everyone.... read article

Dynamically Named Static Method Calls

24/06/2009 00:34 Paul Norman 0 comments

Something that is being added in PHP 5.3.0 but is sorely missed in current versions is the ability to call a static class method from variables. It is something that is occasionally very useful (e.g. you have a validation class triggering other regional classes) and is already possible with standard class calls. Thankfully it's very easy to simulate with eval...... read article

Asynchronous cURL Requests

15/06/2009 18:08 Paul Norman 0 comments

A possibly underused technique available to PHP developers is the ability to spawn a background PHP script without JavaScript. All you need to do this is the cURL library and a few lines of code. Let me explain, suppose you have a script that is going to take minutes (or longer) to run, you don't want to sit looking at a blank screen, and your users certainly won't! In this kind of scenario you can separate out that logic to a background file and leave your view free for other things, perhaps to query the database to see how the background process is doing?... read article

Spin Text For SEO - A PHP Spinner

15/06/2009 17:10 Paul Norman 0 comments

I recently had an SEO expert give us a few hours of his time to provide some suggestions to compliment our SEO strategy. One of the techniques that he introduced I was so impressed with (due to it's utter simplicity) that I am kicking myself for not thinking of it before! Basically, if you have 'doorway' pages into your site (e.g. you have pages for 'Cambridge Widgets' and 'Preston Widgets' and alike) and want them to be dynamically generated, from the same content, but not to suffer horrible duplicate content penalties, you can use a 'spinning' function to generate contextually similar, different, content. The original concept is here, but I have enhanced it a bit to better suit my needs.... read article