Author Topic: Echo Or Print?  (Read 659 times)

Offline Tribal

  • Level 22
  • *
  • Posts: 256
  • Reputation: +1/-1
    • View Profile
Echo Or Print?
« on: November 15, 2008, 01:31:30 PM »
Between echo and print what do you use? Is it down to personal preference? What one floats your boat?

Offline Waizujin

  • Level 15
  • *
  • Posts: 132
  • Reputation: +1/-0
    • View Profile
Re: Echo Or Print?
« Reply #1 on: November 15, 2008, 02:45:11 PM »
http://ezinearticles.com/?The-Difference-Between-PHP-Echo-and-Print&id=1457800

That has some good info on it, I ALWAYS use echo, I think it is just easier and nicer to use.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Echo Or Print?
« Reply #2 on: November 15, 2008, 03:27:08 PM »
echo has one big advantage over print... it has 20% less letters to type :D


There are also some theoretical advantages:
- it is faster in some cases (when you use , to separate values since , it is slightly faster than .)
- it uses less memory (it has one letter less so the filesize is a bit smaller so the script needs slightly less memory to load and parse it - it is not valid if you use PHP accelerators)
- you save the server disc space (one letter less, which can led to even 20-50 bytes savings per file!)
- it can save your development time (since you can not be brainwashed by someone that echo is better than print and need to rewrite the whole code since you already have echo everywhere)
- it makes your keyboard live span longer (one letter less to type = less keyboard intake)
- it is better for your health and eyesight (if you type one letter less then you need to spend slightly less time in front of the monitor so your eyes get less damage, the same goes for you spine (sitting in a bad position) and hand/fingers degeneration)

So yes, echo is far, far better :D

Offline Tribal

  • Level 22
  • *
  • Posts: 256
  • Reputation: +1/-1
    • View Profile
Re: Echo Or Print?
« Reply #3 on: November 15, 2008, 03:34:46 PM »
lol

Very valid points Chris. I did not realising printing was so bad for your health.

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Echo Or Print?
« Reply #4 on: November 15, 2008, 04:39:45 PM »
Haha...
Print has a return value, but I've never actually used it for that purpose, so I think in most cases, echo will do just fine :)

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal