PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

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
?>



More strings PHP Questions

How do I make the first letter of a string uppercase?
How do I remove trailing whitespace from a string?
How can I repeat a string variable several times?
How do I make sure a string is a certain length?
How do I convert newlines to HTML line break tags?