This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Control Flow: Switch Forum

View Course » View Exercise

711 points
3eec9e54bd3f1602589d3416889bcf36?s=140&d=retro
Submitted by
Milos Vranic
over 3 years ago

Is there any difference between ' ' and " "?

As far as I can see its all the same when i am writing or am I mistaking?


1 vote

permalink

What Milos meant was, " I know it has a difference, I just don't know what".

You will use " " when you are using strings (text) and you do not want the text between the " " to be taken literal.

When you use ' ' you are telling php to take whatever you put between the ' ' literally (like a location to a file on your server)

144 points
67594433cd277ff2ccc12493a08dc462?s=140&d=retro
Submitted by
mickeysinonehand
over 3 years ago


0 votes

permalink

basically within single quotes php will display it exactly as it is typed.
echo 'my name is $name'; will print

my name is $name

but if you put it in double quotes php will evaluate the variable and display the value:
echo "My name is $name";

prints

My name is Bret

426 points
9a74e1277d8e32358137a88e715f067c?s=140&d=retro
Submitted by
Bret Wagner
over 1 year ago


-18 votes

permalink

There is huge difference google it

22 points
52598d50abf821b816004d5c_303815619
Submitted by
Ndrom
over 3 years ago

2 Comments

3eec9e54bd3f1602589d3416889bcf36?s=140&d=retro Milos Vranic over 3 years ago

if you could explain it to me instead of being rude?

52598d50abf821b816004d5c_303815619 Ndrom over 3 years ago

im sorry, im new php to but i know there is huge difference