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

mario2027

Banned
Local time
Today, 04:27
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?
 

accessfleet

Registered User.
Local time
Today, 07:27
Joined
Sep 29, 2010
Messages
91
welcome to the neighbor. What version of access do you spend your time and effort on?
 

accessfleet

Registered User.
Local time
Today, 07:27
Joined
Sep 29, 2010
Messages
91
I think echo is a screen print and print is a printer print.
 

vbaInet

AWF VIP
Local time
Today, 12:27
Joined
Jan 22, 2010
Messages
26,374
If my brain serves me well they are pretty much the same but print() can return a value.
 

Yesideez

New member
Local time
Today, 12:27
Joined
Jun 28, 2011
Messages
5
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.
 

bparker1084

New member
Local time
Today, 04:27
Joined
Oct 31, 2012
Messages
9
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.
 

ericlewis107

New member
Local time
Today, 04:27
Joined
Dec 1, 2012
Messages
2
[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

Top Bottom