Home >> PHP - MySQL PHP with example codes - 1.2 [Page 9] Article by: Shelton Manage Friday, 22nd May, 2009
Single vs. Double Quotation Marks
In PHP it's important to understand how single quotation marks differ from double quotation marks. With the echo() and print() statments you can use either.
These charactors have special meanings when used within double quotation marks. Escaped Charactors
Code - Meaning \" Double quotation marks \' Single quotation marks \\ Back slash \n New line \r Carriage return \t tab \$ Dollar sign
Ex: $var = 'test';
The code echo "var is equal to $var"; will print out var is equal to test, whereas the code echo 'var is equal to $var'; will print out var is equal to $var.
Using an escaped dollar sign, the code echo "\$var is equal to $var"; will print out var is equal to test, whereas the code echo '\$var is equal to $var'; will print out \$var is equal to $var.
Single quotes will always display excactly what you type, exept for the escaped single quote (\') and the escaped backslashed(\\).
Ex: quote_vs.phps | quote_vs.php
Page: First - 1 2 3 4 5 6 7 8 9 10 - Last
|