Login |  Register 
I've learnt so much after subscribing to read your exclusive articles!
Nick
 

Quote magic

You can do a lot of cool things with quotes by mixing and matching quotes. For instance a string can be written with a mix of quotes so that a single quote is shown in the output text.
echo "I am tryn' hard to learn PHP!";
Which will output
I am tryn' hard to learn PHP!
The alternative would be to escape the quotes so:
echo 'I am tryn' hard to learn PHP!';
The escape character in PHP is as you may have noticed . The reason you have to escape the single quote in this example is because the string is opened and closed with only single quotes. Another useful feature is that with double quotes you can include a variable directly in the quotes. So
$name = "Dominic";
echo "Hello there $name.";
Which will output
Hello there Dominic.

Comments to date: 1. Page 1 of 1. Average Rating:
cdefgh   4:18am on Friday, December 21st, 2012 
give me more.....................

security image
Written by Dominic Skinner
Last Updated: 2011-10-25 16:00:38