Archive for the ‘PHP’ Category

PHP Imagecreate & Different File Types

Posted on January 22nd, 2008 in PHP | No Comments »

For a recent little bit of PHP scripting, I wanted to grab an image off of a remote server (not for any nefarious purpose!) and manipulate it in PHP (with GD). Read the rest of this entry »

PHP Get File Extension

Posted on January 13th, 2008 in PHP | 8 Comments »

Over time, I've seen a wide range of scripts which for one reason or another have had the need to grab the extension from a file name or path (E.g. "gif" from "mypic.gif"). Oftentimes the solution tends to fall back on what the task appears to need: string manipulation. Though, as you'll see, this may not be the best approach to take.

Read the rest of this entry »

PHP Variable Names: Curly Brace Madness

Posted on January 12th, 2008 in PHP | 5 Comments »

Most PHP coders will know that one is able to specify variable names in the following format, generally within double-quoted strings, however much they from on it:

$str = "Hello ${username}, you look nice today.";

However, that's not the only way to use the brace syntax!

Read the rest of this entry »

PHP Variable Switching - How not to do it!

Posted on January 5th, 2008 in PHP | No Comments »

Over on TalkPHP, there is a wee contest running with the essential idea being to swap around the values belonging to two variables in 8 lines or less. There are very simple, very obvious ways of doing this which you would normally use (I don't think I've ever actually had to swap the values of two variables in real coding!) but for fun, the entire point of the contest is to be creative with the solutions.

We are presented with

$a = 1;
$b = 2;

and quite simply, the aim is to end up with $a having a value of 2 and $b having a value of 1. Easy!

Read the rest of this entry »

TalkPHP: Part 2 - Currency Converter with Automatic Conversion Rates via XML

Posted on December 9th, 2007 in PHP | 2 Comments »

Using SimpleXML to acquire the conversion rates, and storing it in JSON format to be used in the conversion itself. This article introduces some rather impressive functionality to further your PHP skills.

read more | digg story