What's the difference between PHP echo() and PHP print()? (1 Viewer)

mario2027

Banned
Local time
Yesterday, 20:02
Joined
Dec 2, 2010
Messages
1
What's the difference between PHP echo() - phpkode.com/tips/item/php-echo/ and PHP print(),especially in the execution time?
 
welcome to the neighbor. What version of access do you spend your time and effort on?
 
I think echo is a screen print and print is a printer print.
 
If my brain serves me well they are pretty much the same but print() can return a value.
 
echo and print are essentially the same except print will append a new line onto the end of the output.

This can be handy if you're wanting to keep the HTML easily readable in the browser when you view source if you need to keep it readable but I prefer to use echo all the time and when I need a new line I use PHP_EOL instead like this:

PHP:
echo '<strong>This is some HTML</strong'.PHP_EOL;

I use echo because I've always used it - it's down to personal preference what you use. If there's any difference with execution times it'll be so small it's not worth worrying about.
 
Echo can take more than one parameter when used without parentheses and does not return any value while Print takes only one parameter and always returns 1.
 
[FONT=Verdana, sans-serif]In PHP, echo is not a function but a language construct. And print is not a function but a language construct. However, it behaves like a function in that it returns a value.[/FONT]
 

Users who are viewing this thread

Back
Top Bottom