0

Possible Duplicate:
Difference between single quote and double quote string in php

Hi all

I am very new to PHP and I wanted to know what is the difference in use of ' ' and " " ?

Thanks

Community
  • 1
  • 1
Yoni
  • 553
  • 3
  • 14
  • 24
  • 6
    See the [strings chapter](http://php.net/manual/en/language.types.string.php) in the manual – Pekka Feb 09 '11 at 09:13
  • 2
    If something is so basic you *know* you can easily look it up, *don't waste other people's time*, please. – Dan Grossman Feb 09 '11 at 09:23
  • Please refer this link http://stackoverflow.com/questions/3446216/difference-between-single-quote-and-double-quote-string-in-php – Pradeep Singh Feb 09 '11 at 09:18

3 Answers3

3
$name='RkReddy';

echo "$name hi hello"; //op-RkReddy hi hello

echo '$name hi hello';//op-$name hi hello
Alberto Zaccagni
  • 30,779
  • 11
  • 72
  • 106
Karthik
  • 1,428
  • 3
  • 17
  • 29
0

Nothing much, but when using double quotes you can use a PHP variable inside the string, and the string will output the variable's value. When using a single quote it will output the variable's name without parsing the actual value. IE.:

$something = "A nice little variable";
echo "$something is printed out"; //output: A nice little variable is printed out
echo '$something is not printed out'; //output: $something is not printed out

Hope this helps!

dande
  • 233
  • 2
  • 11
0

Double quotes evaluate the content of the string, the single quotes don't.

$var = 123;
echo 'This is the value of my var: $var'; // output: This is the value of my var: $var
echo "This is the value of my var: $var"; // output: This is the value of my var: 123

It WAS a perfomance issue too, 'cause evaluation time affects the interpreter, but nowadays with the current (minimum) hardware it's not an issue anymore.

lucke84
  • 4,516
  • 3
  • 37
  • 58