PHP

Posts about the server side scripting language PHP

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: 

PHPNW 2010 Tickets Now On Sale

Sunday, June 20, 2010 - 22:24

Saturday 9th October 2010 will see the third PHPNW conference in Manchester, a conference devoted to all things PHP. PHPNW is a community of web developers, web designers and anyone else interested in PHP, from the North West of the United Kingdom. The monthly meetup is held on the first Tuesday of every month in the Revolution bar in Deansgate Locks. There is also an active mailing list.

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: