Which one is recomended? echo ("Some_text") or echo "Some_text" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Which one is recomended? echo ("Some_text") or echo "Some_text"

OK I got it.. echo behaves like a function but it really is a Language constructor... so, in this diverse world of navigators, cell phones and tablets someone like me start to wonder... which one is better to use (in term o compatibility): echo ("Some_text") or echo "Some_text"... and is there any exception to the rule where is better to use the other way around?

11th Jun 2016, 3:22 PM
Nelson Urbina
Nelson Urbina - avatar
8 Answers
+ 6
it's both possible but I only use echo "some_text” and there isn't a compatibility problem. The parentheses aren't necessary because echo isn't a function.
12th Jun 2016, 1:07 PM
Patrick G.
Patrick G. - avatar
+ 2
Hmm as far as I know php converts everything to the right type at the right time. So when you use echo, php automatically converts the value to a string... $number=1; echo $number; outputs 1
12th Jun 2016, 2:27 PM
Patrick G.
Patrick G. - avatar
0
I thought the parentheses were to indicate that it was a String...
12th Jun 2016, 1:43 PM
Nelson Urbina
Nelson Urbina - avatar
0
mm.. but that is in the case that you put a variable after the echo... but if you want the word "hello" to appear in the browser and write: echo hello; You will get and error...
12th Jun 2016, 2:39 PM
Nelson Urbina
Nelson Urbina - avatar
0
for sake of consistancy i use echo( "..." ) ;
20th Jun 2016, 8:20 PM
Egon Verbakel
Egon Verbakel - avatar
0
well using the echo("....") seams more professional (makes your code look good and clean) but I does not matter, it does the same thing as the echo "...". So just choose one and stick to it.
1st Jul 2016, 10:41 PM
Benjamin
Benjamin - avatar
0
Nelson Urbina the double quotes " .." are used to indicate that any thing is a string not the parenthesis.
1st Jul 2016, 10:45 PM
Benjamin
Benjamin - avatar
0
the best ways is echo "....";
16th Jan 2017, 3:51 PM
koko