Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,464 members, 7,812,418 topics. Date: Monday, 29 April 2024 at 01:05 PM

What's The Difference Between Php Echo() And Php Print()? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / What's The Difference Between Php Echo() And Php Print()? (1112 Views)

Difference Between Computer Science And Computer Engineering / Asp.net And Php Which Is Better / Difference Between A Programmer And A Web Developer? (2) (3) (4)

(1) (Reply) (Go Down)

What's The Difference Between Php Echo() And Php Print()? by mario2027(f): 3:32am On Dec 20, 2010
What's the difference between PHP echo() and PHP print(), especially in the execution time?
Re: What's The Difference Between Php Echo() And Php Print()? by mikkytrio(m): 5:31pm On Dec 20, 2010
echo
hello world
processing time for a hello world program = 0.030235052108765

print
hello world
processing time for a hello world program= 3.7908554077148E-5

printf
hello world
processing time for a hello world program= 3.504753112793E-5

i hope this answers your question
Re: What's The Difference Between Php Echo() And Php Print()? by Thatdave(m): 10:22pm On Dec 20, 2010
Bro
In all your php scripting forget "print" always use "echo"
With single or double quotes depending on the content of the echo.

In Php print is like homo erectus and echo is like homo sapiense
Bottom line
Never use print in your php life bc there is always an echo.

DaveozoalorATgmail.com
Preparing for my php exam in January.
Re: What's The Difference Between Php Echo() And Php Print()? by kanirip: 12:20am On Dec 21, 2010
It is not that straight-forward as to just say 'Use echo'.

Apparently( I say 'apparently' because I am yet to test this and as such can not say it authoritatively) echo is faster because it doesn't set a return value on execution but I think that there are other factors that you should take into consideration:

http://stackoverflow.com/questions/1006586/is-there-any-difference-between-print-and-echo-in-php-closed

It has some comments regarding the usefulness of the print statement and maybe you would want to look at that before deciding to use echo wink
Re: What's The Difference Between Php Echo() And Php Print()? by Nobody: 9:03am On Dec 21, 2010
I think in Output Buffering there's a difference
Re: What's The Difference Between Php Echo() And Php Print()? by joefazee(m): 4:29pm On Dec 21, 2010
I hardly use echo/print/printf due to template engine (smarty), my best friend is var_dump and print_r for debugging . but i think echo is faster. just develop your own coding standard.

(1) (Reply)

The Need For The First Nigeria Owned Billion Dollar Company In Nigeria / Bash Shell Vulnerability Affects Linux,unix And Mac OS X / Plz Apart From NIIT, Any Other IT Institute In PH.. Rivers State

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.