Code Samples

The following scripts are intended as complete and concise examples of possible coding scenarios. The aim is to illustrate the standard of coding that simpler solutions provides and are not necessarily to be seen as real world coding solutions (more complex examples can be found here).

The examples given below are to give an indication of how we pride ourselves on producing well structured, well documented PHP code that is efficient and elegant as well as being readable and re-usable.

How to give any youtube video a thumbnail of your choice

by John McGeechan

overview

Anyone who has loaded up a video on youtube had faced the frustration of being forced to use a choice of one of 3 random images. Youtube seems to have a maniacal obsession with not allowing users to specify their own chosen thumbnail for a video - there may be a good reason for this btw, I just don't know what that reason is. You can specify the thumbnail if you are a youtube partner, but as of the publication of this article (2013-07-18) it certainly isn't the case for a regular youtube account.

Signature Verification

by John McGeechan

The signature verifier script provides a simple way to validate the arguments passed to a function. Most functions sanitize their arguments before proceeding. Often this is via a set of repeated checks ie checking that a required field is not null or that it is the correct data type (array or int for example). If a function requires many arguments then this can result in a lot of code before the function can start it's actual work. The aim of this class is to abstract out as much of this as possible to improve readability and cut down on code duplication.

Literal Handling

by John McGeechan

The literal handling script illustrates a simple way of providing multi lingual capabilities to a website. Instead of having hard coded string literals within scripts, a simple call can be made to the literals class which will look for a match for the requested literal and the particular language it was requested in. The base literals class is extensible so that each site script can abstract it's own literals away into a seperate literal handling class.