PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

What is the difference between ' and "?


When you use echo and print you may sometimes wonder which to use or what the difference is. This is a very common question and source of confusion.

The single quotes will print everything inside them literally, including variables, e.g. $var will print as $var, whereas with double quotes the contents will be interpolated.

Here we make the difference clear with a natty example:

<?php
$trings 
"No strings attached";
echo 
'$trings'//$trings

echo "$trings"//No strings attached
?>



Comment on this Question and Answer >>>

ASK A QUESTION

More strings PHP Questions

How do I reverse a string in PHP?

How do I convert characters to HTML entities using PHP?

How do I find the position of a letter in a string in PHP?

How do I replace a word in a string in PHP?

How do I convert newlines to HTML line break tags?



Custom Search