Single or double quotes in PHP programming are used to define a string. But, there are lots of differences between these two.
Single-quoted Strings: It is the easiest way to define a string. You can use it when you want the string to be exactly as it is written. All the escape sequences like \r or \n, will be output as specified instead of having any special meaning. Single-quote is usually faster in some cases. The special case is that if you to display a literal single-quote, escape it with a backslash (\) and if you want to display a backslash, you can escape it with another backslash (\\).
Below program illustrates the Single-quoted Strings:
I am a geek. It'll be interesting to know about the string. A \ is named as backslash. This is a portal for $string. This is a portal for \n geeks.
Double-quoted strings: By using Double quotes the PHP code is forced to evaluate the whole string. The main difference between double quotes and single quotes is that by using double quotes, you can include variables directly within the string. It interprets the Escape sequences. Each variable will be replaced by its value.
Below program illustrates the Double-quoted Strings:
I am a geek. It'll be interesting to know about the string. This is a simple string. The word is ABC.
- How to get a substring between two strings in PHP?
- Pairs of complete strings in two sets of strings
- Append digits to the end of dupicate strings to make all strings in an array unique
- Difference and Similarities between PHP and C
- PHP | Sort array of strings in natural and standard orders
- Difference between try-catch and if-else statements in PHP
- Difference between isset() and array_key_exists() Function in PHP
- What is the difference between the | and || or operator in php?
- What is the difference between public, private, and protected in PHP?
- Difference between require-dev and require in PHP?
- What is the difference between HTTP_HOST and SERVER_NAME in PHP?
- What is the difference between is_a() function and instanceof in PHP?
- What is the difference between echo, print, and print_r in PHP?
- What is the difference between array_merge and array + array in PHP?
- What is the difference between a language construct and a “built-in” function in PHP ?
- Difference between “!==” and “==!” in PHP
- Difference between array() and  in PHP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : MeghaKakkar