PHP
Testing 301 Redirects Using PHP
Tue, 01/03/2012 - 17:03 | by philipnorton42I'm always writing bits of script to test things out and I thought that I would start making a record of them in case I need them in the future. This is a little script that will loop through the contents of a text file and validate that a bunch of 301 redirects point to the place they are meant to point to. This script assumes that the redirects are already in place on the server, but this is what I was testing. Here the format of the redirects text file.
Simple PHP Code To Get last.fm Last Played Tracks
Thu, 12/01/2011 - 09:52 | by philipnorton42The other day I was approached by a friend (Julie Cheung) and asked if I could create some code that would display a list of last played tracks from last.fm. Julie isn't a PHP developer and so the code I gave her had to be easily understandable so that she could edit it herself if needed. The following code is what I came up with.
Creating A Thumbnail Of A Word Document With PHP And LiveDocx
Sat, 09/24/2011 - 14:25 | by philipnorton42In any list of documents in a system it is a good idea to add some thumbnails of the document so that your users can get a quick overview of what a document looks like before downloading it. This is a good alternative to just displaying an icon of the document type.
Creating Word document icons is very simple thanks to a service called LiveDocx. LiveDocx was created as a web service to allow the easy creation of most document formats from a simple template. However, it is possible to send a normal Word document as the template file and get an image of the file in return.
Desaturate Images With PHP
Tue, 09/06/2011 - 18:11 | by philipnorton42To desaturate an image means to remove all non-greyscale colours from it, essentially creating a black and white version. To do this you can use the function imagecopymergegray(), which is part of the GD image library. This function is a little difficult to figure out, but what is does is sample one image into another and optionally changing the amount of colours that are kept during the sampling process. The function can be made to sample just a section of the image, or the whole thing. The parameters of the function are as follows.
Drupal Login Destination Based On User Role
Fri, 08/19/2011 - 10:52 | by philipnorton42The Login Destination module is a neat little module that allows site admins to customize where the user will be sent to when they login. It provides a few of different ways of customizing, including a PHP snippet box that allows fine grained control.
PHP Question: Post Variables
Fri, 07/29/2011 - 17:10 | by philipnorton42Question
Take the following HTML form.
<form id="form" name="form" method="post"> <input type="text" name="number" value="0" /> <input type="submit" /> </form>
What is the output of the following PHP code after the above form has been submitted, and why?
if ($_POST['number'] === 0) {
echo 'number is zero';
} else {
echo 'number is not zero';
}