Thursday, March 12, 2009

Two Programmer's Traps

I was writing some PHP and inadvertently wrote '\r\n' for a carriage return for email when it should be "\r\n". The first case produces an unwanted 'literal' string of 4 characters whereas the second produces the the desired control characters and is seen as two characters.

The second trap I fell into was reading some XML if there was only one data element (in this case image names) then it returned a variable if there were more than it was an array, pity it doesn't default to forcing the first case to be an array with just one entry.

Labels: ,

0 Comments:

Post a Comment

<< Home