Avatar ·

What is the difference between strings in single and double quotes in PHP?

Hello everyone! I just started learning PHP and came across something I don't understand. I see that strings can be declared both in single quotes ('example') and double quotes ("example"). The result seems the same — both are strings. But I noticed some strange behavior. Here's an example code: ```php $name = "Ivan"; echo 'Hello, $name!'; // Outputs: Hello, $name! echo "Hello, $name!"; // Outputs: Hello, Ivan! ``` Why does the first case output literally $name, while the second outputs the variable value? Is this related to escaping? I tried writing echo 'Hello, \n'; — it just printed \n, not a newline. In double quotes, \n works as a newline. Please explain what the fundamental difference is between these two types of strings? When should I use which? Are there any