I want to know where and when I have to use single quote and double quotes in PHP ?

Recommended Answers

All 2 Replies

Some of the references for this are:-
1. tizag
2. php manual

Well, you can use both whenever you want. But, they've different response. For example:

$name = 'John';
echo 'My name is $name';     // returns My name is $name
echo "My name is $name";     // reutnrs My name is John
echo 'My name is ' . $name;  // with single-quote, variable should be outside and concatenate with period (.). In this case, My name is John will return

As, you see above, single-quote returns the raw data if you delimit the variable with single-quote, whether double-code returns the processed data.

I'm not expert in this case. But I have to suggest like that.
If you have double-code in value, quote with single-quote otherwise double-quote in similar case.

Hope this help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.