Regular Expression for variable names

So I needed to grab all variables from a script to do various things with, and spent a while tracking down the regular expression to grab valid variable names. The official page on Regular Expression for variable names states ‘A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.’, which is purely the labeling rules for everything after the $.

As well as this we need to also tell it to look for the $ itself, and to output an array of the variables and just the variable names.

$string = '$Lorem ipsum dolor sit $amet, consectetur '$adipiscing' elit. Vestibulum nulla magna, tristique sit amet tempor ornare, iaculis ut sapien.';

This should output:
Array ( [0] => Array ( [0] => $Lorem [1] => $amet [2] => $adipiscing ) [1] => Array ( [0] => Lorem [1] => amet [2] => adipiscing ) )

10 Good Practices for Web Developers

When I look back down the career path of web developer I have taken, I wish I could go back in time and tell myself some of the best practises and tips I now use daily. These tips have helped save myself a lot of time and effort, but if I had of known these from the start then life would have been a lot easier.

1. Dont Repeat Yourself (DRY)

This seems like an obvious thing, but when working on multiple projects, over time you start to see ways you can improve your most used snippets of code. As a PHP developer I frequently use mysql_connect(), but have gotten to the point I dont even think about it as I have it included at the top of all my scripts. I just need to change the constants to define username, password, and database for the various projects I use it on. This can be further improved by adding conditional statements to differentiate between live and developement environments. This is an excellent example of evolving code.

2. SVN (Sub Version)

Once upon a time I used to connect to FTP’s and make changes directly, or work on a copy locally and then mass upload the files to the live server. This is all well and good, but for working on multiple or very large projects this method quickly gets out of hand. There’s the potential to accidentally overwrite more up to date files, forget to upload certain files critical to the website, and end up with whole copies of files and folders you dont really need, but dont want to delete ‘just in case’.

With SVN, you can just login to SSH and execute the command ’svn up’ and this will update your copy of the code to how it stands in the SVN repository. As you commit your work to SVN, it will create version numbers, or revisions, that will allow you to roll back your code to previous versions quickly and easily, and mean its extremely difficult to erase any progress you have made by accident.

As well as this, branches and tags enable you to create projects that off shoot the main trunk of development and enable you to manage many projects using your own basic website framework of code.

Subversion THE Book

3. Firefox Plugins

Firefox is a very pleasant browser to use on a day to day basis, even if you aren’t a web developer. But the developer tools and plugins it provides makes it a must in any good web developers toolbox. Firebug, Web Developer Toolbar, and Greasemonkey are all very good for picking apart code and helping to debug when things aren’t going as planned. Also you have Adblock and Flashblock which stop pesky ads and big flash panels popping up when you dont want them to. Other good ones to mention are YSlow which analyses your website speed and what is holding it back, and HTML Validator, which shows markup errors and warnings.

4. Use Pretty URL’s

There are multiple benefits of using mod_rewritten URL’s, and the most common people would think of is its SEO value. This is true as it allows extra keywords to be used in the target links to the page. However the main reason I would use pretty URL’s is because it looks so much neater to your user, and is more logically layed out and presented. You can create more of a hierarchy and show your webpages in categories your user would expect them to be in, rather than a URL that says index.php?view=somepage&cat=randomcategory&page_id=77354

10+ Mod_Rewrite Rules You Should Know

5. CSS Reset

Due to the joys of browsers that ignore web standards *cough* Internet Explorer *cough*, usually when you build a website, come to view it in another browser and it looks nothing like you expected. A good way to remedy this is to run a CSS reset, which resets all the different ways browsers interpret styles, and should then make them all act roughly the same. Other good ways to achieve this is to use a CSS framework such as Blueprint.

6. To use tables, or not use tables

In the web development community, the use of tables is highly frowned upon. This is due to the fact that in the early days of the internet and HTML, tables was the easiest way to create a layout and structure for your site. As CSS support has improved and gained functionality there are now much more efficient methods to creating layout using divs and lists.

That said though, I have seen people trying to layout tabular data using these methods, and although theres nothing wrong with that, its really over complicating things. Tables are perfectly fine to use, for the reason they were intended.

7. Virtualisation

Website testing is easily the least ‘fun’ part of being a developer, mostly thanks to the previously mentioned lack of standards for certain browsers. Thankfully virtualisation makes things slightly easier, as it allows self contained environments where you can setup an operating system install, within your desktop. This allows you to run various OS’s within your main ‘host’ OS.

This way you can test the main versions of all major browsers, in multiple operating systems so you can ensure it looks good for all the most frequently used combinations of OS and browser. There are a few applications that do this, such as VMWare, VirtualPC, and Virtualbox. We find Virtualbox to be the best, as its free, has good community support, and is available for Windows, Linux, and Macs.

8. Templates

When building a site just in HTML, you have the same basic elements in all of the .html files. Elements such as the header, main navigation, footer, etc. If you want to add a link to your navigation, this means the painful task of copying and pasting code between all of your pages, not fun! PHP makes life a lot easier by giving us the include() function. This allows you to pull in or ‘include’ scripts in your code, as if they were typed in there directly.

I find the best way to use this for templates is to have your index.php file as your outter template, and to use include and GET variables to populate the main content part of the template. You can make this more advanced by adding a check to ensure the file exists, block out viewing of certain files (such as the index.php itself), and point any non existent links to a custom 404 page.

9. Finding the right IDE (Integrated Development Environment)

As a developer your IDE, or coding interface, is a very important tool for productivity and creating clean, error free code. Useful features include sytax highlighting, error notification, code completion, version control, and live ftp editing. Whatever your operating system, be it Windows, Linux, or OS X there are a wide selection to choose from, some tied to one OS, and others multi platform.

The Big PHP IDE Test: Why Use One And Which To Choose

10. Wireframes, Sitemaps and proper planning

Wireframes are used as a representation of a websites layout and structure in its simplest form, focusing on basic elements, without styling or images. This saves time by ensuring you or your clients dont get caught up in colours, typography, and stock images, which could potentially subtract from an interface design which would otherwise be liked. Also it helps to keep everyone on the same page, and can be used as reference for designers, developers, and clients alike.

These are also backed up by sitemaps, which show a users progression through a website, and how you navigate between pages / areas of the site. This can also be represented on interactive wireframes by making links and forms clickable to the appropriate pages.

All You Need to Know about Web Design Project Planning and Process
Why Your Next Website Should be Designed with Wireframes
The Importance Of Wireframes In Web Design And 9 Tools To Create Wireframes


This is obviously not a definitive list, it would be interesting to here other developers tips on time saving methods, and things you wished you knew at the start of your career.

Milton Keynes gets Fibre high speed broadband trial

Up until now, Milton Keynes has been living in the dark ages when it comes to broadband. Speeds anywhere close to the ADSL2+ standard of 24Mbps are few and far between, with only the smaller outer exchanges being able to provide anything close to modern day speeds. Most people are still struggling along with 1-4Mbps, which in todays world of streaming video, media rich websites, and online gaming, is way below par.

Milton Keynes Broadband History

The problem with the existing broadband infrastructure in Milton Keynes is that when the new town was initially planned, the price of copper was too high to lay across the whole town. Instead they opted to go for aluminium, which for phone lines is just as good as copper, though back in the 1970’s the internet was barely even heard of, let alone broadband. Because ADSL signal is not carried as well by aluminium, the majority of local broadband users cant get close to the speed they should even when they are not far from the exchange.

Also Milton Keynes is home to one of the countries largest telephone exchanges. ‘Thats great’ I hear you cry? Wrong! The more people on the exchange, the busier and more saturated it becomes. All of central Milton Keynes and surrounding areas run off this exchange (approximately 30,000 premises), which is actually based in Fishermead, not Bradwell Abbey itself. Newport Pagnell, Stony Stratford, and Bletchley all get their own, and are generally not affected by this technological blight of Milton Keynes.

High Speed Broadband is the future!

Fortunately this makes Milton Keynes the perfect candidate for BT to trial their new Fibre network, hopefully going ahead as of January 2010. Fibre is totally different to the way broadband works when going down a phoneline, it is specifically meant for handling data, in vast quantities. BT will be upgrading the Bradwell Abbey exchange to utilise FTTP (Fibre To The Premises) or FTTH (Fibre To The Home), which should enable speeds of up to 100Mbps, therefore in some cases providing 100 times the connection speed.

To give an example, most home local networks (using ethernet cable to connect the PC in your study, to your PC in the living room) run at 100Mbps. This means you will have potentially the same transfer speeds between your computer upstairs, and a server on the other side of the planet! This is huge news for Milton Keynes residents and business owners, which have been plagued by sub standard speeds for too long. This town is already a technological and commercial hub, but can only expect more growth and wealth because of it.

How do I get on the trial?

Up until now, BT are remaining fairly hush-hush on the subject. Openreach (BT’s wholesale offshoot that deals in selling its services to other ISP’s such as Sky, Pipex, Be etc) will initially be upgrading the exchange, and then opening up to a range of other hosts to provide this service. This means you should be able to get onto the network without ever actually being a BT customer. Speaking to a BT customer service representative, I was told that when the time comes they will be heavily pushing the service to all areas it will be available in.

If anyone can provide anymore information or knowledge on the matter, please make a comment below :)

UPDATE: 27/01/2010

The Milton Keynes Broadband Action Group have got a host of new information regarding the trial. You can find this information in full here.

To summarise:
- Any ISP can partake in the trial
- Speeds will be around 100MB down / 15MB up
- Proposed start, summer 2010
- Costs, unknown and dependant on individual ISP’s

Looks good, more information will be added as we find it :)

The SEO Rapper

Search Engine Optimisation is a tricky business. Most non techie people see it shrouded in mystery with Google keeping their cards close to their chest, using their complex search algorithms and ever changing formula to get to that coveted #1 spot.However if you type “SEO” into Google, every man and their dog claims to be an SEO expert, but Chuck, the SEO rapper may just take the prize.

The lyrics he speaks about in his series of raps explain about SEO / web design and development with almost comedic accuracy, and his latest offering “Design Coding” is nothing short of brilliant. I don’t even like rap music (more into my heavy metal etc), but the way he describes my daily cave-eats in such an unusual method is awesome.

“Please do not use tables, even though they work fine. When they come to indexing they give search engines a hard time.”

Brilliant! ;) PLEASE watch these on Chucks site below. Click here to check out Chuck’s website

What type of geek are you?

While browsing this months .net, near the back in their random funny links section I came across a poster / wall chart of many different types of geek. As its the new millenium, and most of the internet seem to be embracing their inner geek, its time to ask the question…Which geek are you? Please check out the link below for the original poster. I have spliced together some of my favourites above!

Click here for more.


Finally got around to redoing this as more of a portfolio type site. New theme I am slowly creating myself, basic look is what I want but lots of tweaking to do!

Got a few of my fav projects in the portfolio section, more to come.

Errrm yeah… watch this space :)

Favourite Firefox plugins

Web Developer Toolbar

Session Manager


Firefox Showcase

Adblock Plus

Flash Block

Download Statusbar

Down Them All





Mouse Gestures

Asus EEE 1000 Perfect install with Ubuntu

After having owned my EEE 1000 (linux version) for a few weeks now, I have become obsessed with getting the perfect setup.

The onboard OS Xandros is ok, but I got bored with it after 5 minutes and just didnt feel as nice as Ubuntu has on my other machines. The boot time is pretty good and it ‘just works’, but thats about all it does.


First thing you will need is a USB stick (pref 1gb+) and a way of getting Ubuntu onto it. The distro I went for was Ubuntu eee (Hardy Heron 8.04), but you could use stock Ubuntu(Gnome), Xbuntu (XFCE), etc.

Once the ISO is downloaded, use something like unetbootin to make the USB stick bootable and copy it over. More instructions for this can be found here.

When you have a bootable stick, reboot and hit escape at startup to get the boot menu, choose USB and wait for it to load up.

Once in you get a desktop (as this is a live distro after all), with a single ‘install’ icon. Run this and click through until you reach the partition section. You can either wipe the lot so its just ubuntu, or keep xandros on there for the other half / incase you break anything.

Then setup your user account and press go. It will now start to partition and install.

Once that has done, reboot and you have a fresh copy of Ubuntu. Unfortunately not everything will work, you are initially without working wireless and ethernet, amongst a few other things.

The community seems to think the easiest way to get it all up and running is to install a custom kernel.

To do this we need to manually download the two packages

  1. linux-image-2.6.24-21-eeepc_2.6.24-21.39eeepc1_i386.deb
  2. linux-ubuntu-modules-2.6.24-21-eeepc_2.6.24-21.30eeepc3_i386.deb

and put them onto the eee and run them. Using the terminal, navigate to the directory where you saved the two .deb packages and use this command.

sudo dpkg -i linux-image*.deb linux-ubuntu-modules*.deb

Reboot, and you should have a new entry in your GRUB selection. Choose this. When you are booted up you should have net access, so now its time to update your repositories.


sudo mv -v array.list /etc/apt/sources.list.d/

Install the repository public key:


sudo apt-key add array-apt-key.asc

sudo apt-get update

Finally you need to install the remaining eeepc-optimized kernel components

sudo apt-get install linux-eeepc linux-headers-eeepc

This should have pretty much everything working except the Fn hotkeys, so see how to activate them here. That page has some other useful bits on it too.

Once you have a good working install, back everything up with info from here

Things that now work

  • Sound
  • Shutdown bug
  • Compiz
  • Webcam
  • Wireless
  • Ethernet
  • Fn keys
  • Multitouch

Things that dont

  • Microphone