+ 3

Did someone notice a difference between using echo "some_text" and echo 'some_text'?

12th Jun 2016, 4:59 AM
Nelson Urbina
Nelson Urbina - avatar
6 odpowiedzi
+ 9
When writing variables in double quotes they are parsed, in single quotes they aren't. For example: $x = 'World!'; echo 'Hello $x'; //Output: Hello $x echo "Hello $x"; //Output Hello World!
13th Jun 2016, 10:56 AM
Ah El
Ah El - avatar
0
Ok Patrick... I read somewhere that if you need quotes marks to appear in your text in the browser you use both of them (like your example).. the result in the browser would be: some 'text' Is there another difference besides escaping single and double quotes to the text?
12th Jun 2016, 1:40 PM
Nelson Urbina
Nelson Urbina - avatar
0
Hmm I'm also a little bit confused about this. The only thing I can say is that single quotes should parse faster. There are little differences with using \ in the double and single quotes but I don't really get the point of the explanations in the internet...
12th Jun 2016, 2:32 PM
Patrick G.
Patrick G. - avatar
0
Both are similar but it helps to know strings and characters
12th Jun 2016, 3:00 PM
Jai
- 1
it's completely the same. but sometimes you have to use both of them and then you need two types: echo "some 'text' "
12th Jun 2016, 12:57 PM
Patrick G.
Patrick G. - avatar
- 1
I think it doesn't matter both will work
14th Jun 2016, 7:19 AM
AlexGaming Youtube studios
AlexGaming Youtube studios - avatar