News & Blog

WordPress Plugin Activated

Debugging Why WordPress Won’t Create Plugin Tables On Activation

July 11th, 2013 - Posted by Steve Marks to MySQL, PHP, Web Development.
I’ve wrote small-ish WordPress plugins in the past, however at the moment I’m working on something a little more girthy (can a WordPress plugin be girthy?) where I’m getting to experiment with more of the advanced features. One of these features I’m getting to play ...

List Alphabetical Characters A-Z with PHP

July 1st, 2013 - Posted by Steve Marks to PHP, Web Development.
I wanted to share a really simple way to get all the characters from the alphabet so that they can be easily iterated through. I’ll be using the PHP range() function which, aside from getting characters from the alphabet, can also be used to obtain other ranges, such as numbers. Let&...
Missing Wordpress Admin Bar

Admin Bar Missing From WordPress Website Front End

February 12th, 2013 - Posted by Steve Marks to (X)HTML / CSS, PHP, Web Development.
If you’ve worked with WordPress before you’ll know that when logged into a WordPress back-end, a bar will appear at the top of the website when viewing the public facing site. The admin bar allows the logged in user quick access to perform common tasks and looks omething like s...

PHP Function to Compare Floating Point Numbers

September 14th, 2012 - Posted by Steve Marks to PHP, Web Development.
If you’ve found this post you’re probably, like I once did, experiencing problems with comparing floating point numbers in PHP. A section on the official PHP website confirms the difficulty in doing this and why it can be problematic. And I quote… As noted in the warning ...

Format a Number Within a String Using PHP preg_replace() Function

September 14th, 2012 - Posted by Steve Marks to PHP, Web Development.
Let’s imagine we have the following string: I owe 1000000 GBP to the bank. I shall pay 2500 GBP each month for the following 1000 years. The above statement is luckily not true, however it is a good representation of a scenario where we have numbers contained within a string that we ...

parseInt() Function Returning Zero For Numbers ’08’ and ’09’

July 26th, 2012 - Posted by Steve Marks to Javascript / jQuery, Web Development.
A very quick one this but one that had me stumped when trying to work with numbers in JavaScript earlier on. Lets imagine we have the number eight or nine but it’s prefixed with a zero. To run it through parseInt() in JavaScript you might think to do the following: var myNumber = par...

PHP Function to Connect via FTP with Retry Capability

February 21st, 2012 - Posted by Steve Marks to PHP, Web Development.
Let’s face it… If something can go wrong, it will go wrong. This is no exception for FTP connections either. Maybe the remote server is not accessible, the network is down, or the connection times out. PHP comes with a set of useful functions to deal with common FTP operations....

PHP Benchmark – sha1_file() vs sha1(file_get_contents())

September 16th, 2011 - Posted by Steve Marks to PHP, Web Development.
When working on a recent project the need came up to produce a SHA1 hash of a file to allow comparisons between new and existing files. I knew that I could easily create a hash of a file using PHP’s sha1_file() function but I was unsure on the performance and speed of it, bearing in ...

Getting the Time a PHP Script Takes to Execute

July 20th, 2011 - Posted by Steve Marks to PHP, Web Development.
If your working with large resource intensive PHP scripts, or are simply looking to refine and optimize an existing bit of code, one of the steps you might take is to look at how long your PHP code is taking to run. We can do this within the PHP code itself by analyzing the time [...]...

Converting a PHP Array to a Query String… And Back Again

May 18th, 2011 - Posted by Steve Marks to PHP, Web Development.
This is a scenario I have found myself in many times before; needing to convert a PHP array to a query string for use in a URL or POST request, and vice versa. Today I will discuss both methods and how they can be achieved with the aid of two very useful PHP functions; http_build_query() [...