+ 2

Print and echo. Difference?

what's the difference between print and echo?

1st Dec 2016, 12:07 PM
code-or-die
7 Answers
+ 3
Both use to show output stream data to browser. But, echo is faster than print. Use echo for output single data. For array use print_r()
1st Dec 2016, 12:14 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 3
Well, I have not tested it but read on w3schools.com and stackoverflow. it slow because it set a return type. here http://stackoverflow.com/questions/234241/how-are-echo-and-print-different-in-php Yes, you are right on I have to write difference like it return 1 and it only work with one argument. But I was in hurry. Sorry, for that. Thanks for accepting that you down vote my answer.
1st Dec 2016, 1:52 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 2
hey, if you not get angry then I have a question. Why you down vote my answer. I don't think it is wrong. else ignore it if you not do that.
1st Dec 2016, 1:40 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 1
There are no major differences between the two, since they are both used for outputing data. print has a return value of 1, while echo has no return value and echo is said to be marginally faster, although it is not noticeable.
1st Dec 2016, 12:14 PM
David Barzi
David Barzi - avatar
+ 1
Just like manual says : The only difference to echo is that print only accepts a single argument. http://php.net/manual/en/function.print.php http://php.net/manual/en/function.echo.php
1st Dec 2016, 12:16 PM
Ondƙej Doněk
Ondƙej Doněk - avatar
0
It's because correct answer is just these argumenty - but something that one is faster than another? Have you any tests?
1st Dec 2016, 1:44 PM
Ondƙej Doněk
Ondƙej Doněk - avatar
0
echo is faster than print()
1st Dec 2016, 6:30 PM
rahmat jafari
rahmat jafari - avatar