+ 2
Difference bw ' & "
'hello world' "hello world"
3 Respuestas
+ 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'
+ 2
tnqs
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