Difference between Single quotes ‘ and Double quotes ” in PHP

In this tutorial we will learn about the difference in single quotes and double quotes. Theoretically if we understand then single quotes doesn’t parse the data and double quotes is said to be interpreted.

In simple words if we understand then if we write anything in double quotes then it passes the value in the variable whereas if we write anything inside single quotes then it passes the value as string. We will see it though example to make it clear.

Output:

It shows that if we write within the single quotes it doesn’t parse the data and shows the value as string.

  • One more thing we should know that we cannot use Single quotes within single quotes and Double quotes within double quotes.

This is a wrong way of using quotes and we will fetch an error if it is compiled instead of this we can use the below format:

  • To use double quotes within double quotes and single quotes within single quotes then we have to use skip “\”.

Reference:

Joydeep M
Latest posts by Joydeep M (see all)
Tagged :
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x