Home
Recent Articles
more...    [all articles]
Articles by Catagory
php (12 )
css (1 )
Tutorials
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:-

<html>
<head>
<title>quotes</title>
</head>
<body>

<?php
      $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] [code snippets]

End of Article - Usage of -single quote- and -double quote- with strings in PHP
http://phpmyanmar.com/content/article//usage-of-single160quote-and-double160quote-with-strings-in-php.html

0 comment

Leave your comment

Name

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

<< Type above word in this box

Install Myanmar Font
  • Download the font, (zawgyi-one) here.
  • See how to install the font here.
PhpMyanmar Forum
Feedback (In Eng and Myan)