PHP

Posts about the server side scripting language PHP

PHP TestFest UK 2010 And Testing PHP

Wednesday, September 29, 2010 - 23:16

The UK PHP TestFest this year was held at MadLab in Manchester on the 11th September. I was one of the 12 people who went along to learn about testing the PHP language. So I thought that I would collate some of the things that we went through during the session.

Category: 

Print Image With Fixed Aspect Ratio In PHP

Monday, September 20, 2010 - 10:33

When displaying images added by users it is quite often necessary to resize them in order that they fit into a specific area of the page. Not doing this can cause problems with the images breaking the page layout. The trouble is that if you resize the image absolutely you tend to squash and distort it.

The following function can be used to calculate the width and height of an image to the correct aspect ratio, which will preserve the contents when printed out. This function makes use of the getimagesize() function, which is available as part of the GD library in PHP.

Category: 

PHP Version Number

Saturday, June 26, 2010 - 00:55

Different functions and options are always being added to PHP. Although new versions generally don't create much backward compatibility issues it is usually prudent to write production code that you know will work on servers running a slightly older version of the language.

Category: 

Find A Month From A Given Integer With PHP

Monday, June 7, 2010 - 17:28

If you need to know the month from a given integer (from 1 to 12) then you can use the following snippet. This will return the string "Feb".

Category: 

Parsing XML with PHP

Friday, May 7, 2010 - 00:14

XML data extraction can be a common task, but to work directly with this data you need to understand how PHP parses XML. There are various different functions involved in parsing XML in PHP, all of which work together to extract data from a XML document. I will go through each of these functions and tie them together at the end.

Category: