+ 2

Difference bw ' & "

'hello world' "hello world"

21st Apr 2018, 2:10 AM
vinod Karanam
vinod Karanam - avatar
3 Answers
+ 10
A minor difference is that, if you want to use the same kind of quotes inside your string, you have to escape them (put a \ before them). Otherwise, the extra quotes will end your string too early. Ex: print('Printing "double-quotes" and \'single-quotes\'') #Output: Printing "double-quotes" and 'single-quotes'
21st Apr 2018, 2:21 AM
Tamra
Tamra - avatar
+ 2
tnqs
21st Apr 2018, 2:30 AM
vinod Karanam
vinod Karanam - avatar
0
The do have different meanings in php. $juice = "apple"; echo "$juice juice"; // outputs apple juice echo '$juice juice'; // outputs $juice juice JSON also depends on " vs ' Valid JSON requires " around strings. { "firstName": "Bob", "lastName": "Ross", "age": 56 } is valid { 'firstName': 'Bob', 'lastName': 'Ross', 'age': 56 } is not valid and will throw an error
21st Apr 2018, 8:24 AM
Adam
Adam - avatar