Recent Articles
more...    [all articles]
Related Links
Usage Of - Single Quote - And - Double Quote - With Strings In PHP
Posted By - Ko Ko - January 5, 2007

Summary :
How to use -single quote- and -double quote- with strings in PHP
Printer Friendly Page
Show Myanmar Version show-myanmar-font

Usage of 'single quotes' and 'double quotes' in Strings

In PHP, a string is simply a group of characters.

They can contain:-

  • letters
  • ASCII characters
  • numbers
  • other variables

When you assign a string to a variable (or) echo the string out to the browser, you have to mark the start and end of the string.

The ways of doing this are:

1. Single Quotes:
echo 'Hi there';

2. Double Quotes:
echo "Hi there";

The two methods looks similar but they are slightly different. Look at the following codes:-


$name = "Sally";
echo "My name is $name";
echo "<br>";
echo 'My name is $name';


You will see that the output of above are different.

My name is Sally
My name is $name

In the first code line, a variable was put between a pair of double quote. Its value Sally was displayed by the browser

echo "My name is $name" = My name is Sally

In the next code line, a variable was put between a pair of single quote. Its value Sally was not displayed by the browser.

echo 'My name is $name' = My name is $name

Play around with single and double quotes with different strings and variables and observe the differences.

Posted as - [programming] [php]

End of Article - Usage of - single quote - and - double quote - with strings in PHP

0 comment

Leave your comment


You can type in both English and Myanmar (Use Zawgyi Font)

<< Type above word in this box

PHP Training
Php Snippets
Feedback (In Eng and Myan)