PHP Quotes and Apostrophes - the Difference

Many people seem to be confused with the use of quotes and apostrophes when coding in PHP.

Using apostrophes is the “lightweight” way. Use these when you just want to create a string:
$var = 'This is just plain old text.';Using quotes will provide you with a bit more functionality and in turn is slightly more expensive in execution:

# Use \n to add a new line
$var = "This is the first line\nThis is the second line";
# Include the value of a variable
$var = 'bones';
echo "Don't rattle my $var";

Please note also that PHP will evaluate any text in quotes - it is therefore more efficient to use apostrophes by default and use quotes only when you need them.

Are you a Developer, Designer or Copy Writer? Or Looking For One?

Click here to see 100s of jobs updated every day that you can complete to earn good money. Also find that programmer, designer or copy writer you have been looking for - advertise and get the best guy for your job - click here to find out more

Leave a Reply

Make $100,000/Month - Every Month!

It Works! We Make Our Customers Millionaires! Act now and get $600 bonus and a Free Money Making Website! - click to get started