Print Vs. echo. I recommend echo. Why?..well

Was trying to figure out which was best, since both essentially to the same thing. Managed to find a preformance test done by some other dude.

eh… good I always use echo :beer:

There is only one difference between the 2:

echo returns nothing.
print returns 1 (true) or 0 (false) if it successfully prints.

print has 5 character and echo 4 :slight_smile:

I always use echo, and it seems like a good thing to do, and thanks for the info marble, I always wanted to know, but why would you check to see if it printed? what would stop it?

edit: figured it out, a messed up variable of course

Lol @ T.O. Uhmmm forgot that one… :stuck_out_tongue:

I used to always use print until I read that about the return. I personally don’t see much use in it. I mean if you mispell something it should be obvious if it doesnt show on the screen. Might be useful for debugging.
$debug = true;
if ($debug) {
if (! print $someVar) {
echo “You made a boo boo”;

But that could get pretty redundant.

good info but I’m still gonna use echo because I simply don’t make no mistakes :cool:


Actually, from, it always returns ‘1’ :


(PHP 3, PHP 4, PHP 5 )

print – Output a string

int print ( string arg)

Outputs arg. Returns 1, always.

print() is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list.

ah… any clue what the purpose of it might be?

  • I see you work for 2advanced…

Essentially the return allows you to build larger, more complex expressions in PHP, where echo would not quite work …

For instance, you can incorporate print statements into if()'s, for loops, while loops, and basically anywhere echo would essentially be a noop which would violate the syntax requirements.

I’ve written a quick example, you can view the source at: or run the script at [url=“”]

Hope that helps.

didnt read all of it… but

print is a function :slight_smile: if i remember it correct


print() is not actually a real function