Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 5:16 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 3 posts ] 
Author Question
 Question subject: Difference between PHP echo() and PHP print()?
PostPosted: Fri Dec 03, 2010 2:27 am 
Offline
Newbie
User avatar

Joined: Fri Dec 03, 2010 2:22 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

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


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: What's the difference between PHP echo() and PHP print()?
PostPosted: Fri Dec 03, 2010 12:31 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
The same ??

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: What's the difference between PHP echo() and PHP print()?
PostPosted: Fri Dec 03, 2010 7:41 pm 
Offline
Newbie
User avatar

Joined: Thu Nov 18, 2010 11:56 am
Posts: 49
Has thanked: 0 time
Have thanks: 15 time
Code:
<?php
     print "Hello World! <br />";
     echo "Hello World! <br />";
     // The above outputs the text "Hello World!" on two separate lines.
     // Notice they are identical in output!

     print ("Hello World! <br />");
     echo ("Hello World! <br />");
     // The above are just the same, with parenthesis.
     // Notice both can act like functions, but note they actually aren't.
?>


In all actuality, Echo and Print differ based on how they are structured. Print returns a value much like a normal function would. But despite common belief, Print is not a function, as we can see by the fact that it doesn’t require parenthesis to work (Not to be confused with Printf). Print and Echo are actually both called language constructs, although this isn’t to say that we can’t make Print act like a function.

PHP Echo Vs Print: Which Is Faster?

Echo is faster than print.

Print can be used as part of complex constructs, such as
($b) ? print “True” : print “False”; // or echo ($b ? “true” : “false”);
Also, if you want to use error output (@print”Test”;)
Print is easy because almost every language use it. but most php developers use echo because it is faster and it is sounds cool!

Use what you prefer and easy for you! :sohappy:

_________________
Coding my life with Java, PHP, JavaScript, and Python



For this message the author isuru has received gratitude : msi_333
TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 3 posts ] 
Quick reply


  

 Similar topics
 print clock using JavaScript
 difference between upcasting and downcasting
 print element in 2d matrix
 find the difference between dates in asp.net
 print all files names in folder
 Help for Print using php
 Difference between forward and sendRedirect
 How to print a webcam picture in Jsp
 Print the ASCII Set
 The difference between an Interface and an Abstract class

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 3 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team