...Beauty, cleaning, DIY tips and more - free to join!
   Login   Contact us   Site map   Puzzle Club   Ask a question    Newsletter

The Difference Between Echo And Print In PHP

Computing : Learning PHP

One common question people have is why there are two functions that seem to do the same thing in PHP.

In some books you read, all the programs will use print to print data, whilst in other books you will see echo used.

Do some use echo as it has one less character and others print just because it is more obvious what it does from the off?

Well in practice there is a difference between the two but very few programs use it.

That is that one returns a 1 on success and a 0 on failure whilst the other doesn't.

Echo doesn't return anything whilst print returns 1 on success.

Thus if you ever conceive of a place where this is needed then use print to get a return value and see if the print statement worked.


By: Stephen

Share on Facebook: On Twitter: TwitterTweet this!

  Reply to The Difference Between Echo And Print In PHP

  Receive Our Newsletter




Questions about learn PHP:

Ask question

More Articles:
How to reduce Flash file size
Stay safe online: use an up-to-date browser
How to block pop ups