Based on the response I got from JaTaMan I thought it would be a good idea to add an additional post about single and double quote usage in PHP.
JaTaMan pointed out that a colleague of his used the new line special character in single quotes not knowing that single quotes are literal, what you see is what you get. Because of that I have listed some more detailed examples of usage between single and double quotes – basic but strict standards.
Strings that contain variables can be in double quotes or concatenated between single quotes:
$name = 'Steve Clarke'; $string = "My name is $name"; // My name is Steve Clarke
$name = 'Steve Clarke'; $string = 'My name is '.$name; // My name is Steve Clarke
Using special characters such as newlines and tabs should be placed within double quotes as PHP parses double qoutes:
$string = "This is one line \nAnd this is a new line"; // This is one line // And this is a new line
$string = 'This is one line \nAnd this is a new line'; // This is one line \nAnd this is a new line
Another important factor is escaping. If you need to use a single quote within a single quote string your will need to escape the single quote, like so:
$string = 'My name isn't James Bond';
$string = 'My name isn\'t James Bond';
You could use double quotes so that you do not need to escape the single quote however based on the main point of the two posts PHP will evaluate double quoted strings and add extra processing time, don’t waste time.
The same rule applies for double quotes:
$string = "My name isn't "James Bond"";
$string = "My name isn't \"James Bond\"";
A good rule of thumb to follow is simply use single quotes wherever you are not using special characters or variables. If you want to make this even easier on yourself only use double quotes when using special characters and concatenate variables to single quote strings.