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

**URL:** <https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214>\
**Category:** Uncategorized\
**Created:** [July 20, 2004, 6:54pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214 "2004-07-20T18:54:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mindfriction](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mindfriction/32/172_2.png) [@mindfriction](https://forum.kirupa.com/u/mindfriction)\
**Post date:** [July 20, 2004, 6:54pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/1 "2004-07-20T18:54:31Z")

</div>

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.

[http://dynacker.dotgeek.org/printvsecho/](http://dynacker.dotgeek.org/printvsecho/)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2004, 7:08pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/2 "2004-07-20T19:08:15Z")

</div>

eh… good I always use echo 🍺

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2004, 8:42pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/3 "2004-07-20T20:42:26Z")

</div>

There is only one difference between the 2:

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2004, 8:59pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/4 "2004-07-20T20:59:44Z")

</div>

print has 5 character and echo 4 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2004, 9:06pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/5 "2004-07-20T21:06:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2004, 9:21pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/6 "2004-07-20T21:21:37Z")

</div>

Lol @ T.O. Uhmmm forgot that one… 😛

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2004, 9:32pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/7 "2004-07-20T21:32:17Z")

</div>

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

😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2004, 9:37pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/8 "2004-07-20T21:37:00Z")

</div>

> [@Marble](#):
>
> Lol @ T.O. Uhmmm forgot that one… 😛
> 
> I used to always use print until I read that about the return. I personally don’t see much use in it.

Actually, from [PHP.net](http://PHP.net), it always returns ‘1’ :

> 

**print**

(PHP 3, PHP 4, PHP 5 )

print – Output a string  
**Description**

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2004, 9:44pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/9 "2004-07-20T21:44:37Z")

</div>

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

- I see you work for 2advanced…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 20, 2004, 10:39pm UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/10 "2004-07-20T22:39:03Z")

</div>

> [@Marble](#):
>
> ah… any clue what the purpose of it might be?

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:

[http://www.jeffjirsa.net/jeff/print.phps or run the script at [url=“http://www.jeffjirsa.net/jeff/print.php”]http://www.jeffjirsa.net/jeff/print.php](http://www.jeffjirsa.net/jeff/print.phps)

Hope that helps.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 21, 2004, 12:43am UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/11 "2004-07-21T00:43:50Z")

</div>

didnt read all of it… but

print is a function 🙂 if i remember it correct

Print

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 21, 2004, 4:12am UTC](https://forum.kirupa.com/t/print-vs-echo-i-recommend-echo-why-well/58214/12 "2004-07-21T04:12:07Z")

</div>

> print() is not actually a real function
