Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP practical advantages for using echo over print [duplicate]

Possible Duplicate:
Reference: Comparing PHP's print and echo

I am wondering about the practical and real advantages and reasons for using echo instead of print to write output to the screen.

In many areas of my code I have this sort of thing:

PRINT("<b>".$course_id."</b>");

I understand that print returns a value whereas echo doesn't, however i'm interested to know if there is any real reason to replace the instances in my code (and there are a few unfortunately) of print with echo?

Is it just bad practice to use print in these sort of scenarios or is there reason and benefit to avoiding it?

I am using PHP 5.3.13.

like image 963
crmpicco Avatar asked Sep 04 '26 10:09

crmpicco


1 Answers

From phpbench, echo() is faster than print(). But I think nobody will notice if your code is a few microseconds slower.

like image 179
flowfree Avatar answered Sep 06 '26 01:09

flowfree



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!