Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,482 members, 7,812,494 topics. Date: Monday, 29 April 2024 at 02:13 PM

Single Vs Double Quotes In PHP - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Single Vs Double Quotes In PHP (526 Views)

I Need Olx Or Jiji Classified Clone Script In PHP / Urgent Help To Display Data In Php / 25 Quotes From Blogging Experts At West Africa Bloggers Conference (2) (3) (4)

(1) (Reply)

Single Vs Double Quotes In PHP by maekhel(m): 12:01pm On Jan 06, 2015
Today we will be taking a quick look at Single vs Double Quotes In PHP. This is going to be a very brief tutorial. Most people (myself inclusive) misuse this quotes. Now that I understand where and when they are being used, I decided to share it with you guys.
The Single Quotes (”)
The single quotes will not interpret the value of the variables enclosed in them. The single quotes will output the string as they are without any interpretation. Let demonstrate this with example:

//let declare a variable and assign value to it
$variable = "Tutorialslodge";
echo 'This lesson is from $variable';
When the code snippets above is executed, it will out put: This lesson is from $variable. This is to show that the single quotes will display whatever it contains as it is.
The Double Quotes (“”)
The Double Quotes unlike the Single Quotes will not only output values but also interpret any variables it contains. Let use the same example from above to demonstrate Double Quotes:

//let declare a variable and assign value to it
$variable = "Tutorialslodge";
echo "This lesson is from $variable";
When this code is executed, the PHP HyperText Preprocessor will parse the $variable in the double quotes and replace it with the value which that variable holds. So our code will output: This lesson is from Tutorialslodge.
So you now know when and where to use each of the quotes. Remember if you want your variables to be interpreted, use Double Quotes, hence use Single Quotes.
I hope this tutorial is helpful. Kindly drop your comments, questions, suggestions and views in the box below.
source: http://tutorialslodge.com/single-vs-double-quotes-php/

1 Like

Re: Single Vs Double Quotes In PHP by emmyvet(m): 2:50pm On Jan 06, 2015
maekhel:
Today we will be taking a quick look at Single vs Double Quotes In PHP. This is going to be a very brief tutorial. Most people (myself inclusive) misuse this quotes. Now that I understand where and when they are being used, I decided to share it with you guys.
The Single Quotes (”)
The single quotes will not interpret the value of the variables enclosed in them. The single quotes will output the string as they are without any interpretation. Let demonstrate this with example:

When the code snippets above is executed, it will out put: This lesson is from $variable. This is to show that the single quotes will display whatever it contains as it is.
The Double Quotes (“”)
The Double Quotes unlike the Single Quotes will not only output values but also interpret any variables it contains. Let use the same example from above to demonstrate Double Quotes:

When this code is executed, the PHP HyperText Preprocessor will parse the $variable in the double quotes and replace it with the value which that variable holds. So our code will output: This lesson is from Tutorialslodge.
So you now know when and where to use each of the quotes. Remember if you want your variables to be interpreted, use Double Quotes, hence use Single Quotes.
I hope this tutorial is helpful. Kindly drop your comments, questions, suggestions and views in the box below.
source: http://tutorialslodge.com/single-vs-double-quotes-php/
Ya is helpful thanks
Re: Single Vs Double Quotes In PHP by maekhel(m): 3:04pm On Jan 06, 2015
emmyvet:

Ya is helpful thanks
Glad it was helpful

1 Like

(1) (Reply)

Google Adsence Help / Nigerian Game Developer Need Your Vote To Win A Publishing Contract. / Make Money With Facebook

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.