+ 2

What is the difference between single and double quotes in php

5th Jul 2016, 3:19 PM
Midhun Mathew
3 Respostas
+ 2
There is some technical difference: - single quotes are slightly faster - echo '$var' will output: $var - and echo "$var" will output value of $var
7th Jul 2016, 6:58 AM
forsberg
+ 1
there's technically no difference. You'll get the same result by doing this <?php print("hello world\n"); print('hello world\n'); ?> the reason it's built like this is to give you the chance to nest quotes inside quotes. "he said "hello"." would be interpreted as two strings and a hello in the middle. 'he said "hello".' would be interpreted as one string.
5th Jul 2016, 8:43 PM
Alejandro Aristizabal
Alejandro Aristizabal - avatar
0
forsberg that I did not know! thanks for the knowledge
7th Jul 2016, 6:59 AM
Alejandro Aristizabal
Alejandro Aristizabal - avatar