NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page When programming php do you use....

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


View Poll Results: Print or echo?
print 2 11.11%
echo 15 83.33%
What are you even talking about? 1 5.56%
Voters: 18. You may not vote on this poll

Closed Thread
 
LinkBack Thread Tools
Old 09-19-2005, 02:56 PM THREAD STARTER               #1 (permalink)
Account Closed
 
axilant's Avatar
Join Date: May 2004
Location: /etc/passwd
Posts: 2,178
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
 

Member of the Month
July 2005

When programming php do you use....


print or echo?

I use print(""); I will never use print "";

i will use print $cls[tpl]->fetch("tpl");

I never use echo

I know this is something stupid... but its just something that struck me to ask ^^
axilant is offline  
Old 09-19-2005, 03:03 PM   #2 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
echo("string");

is my format.
mholt is offline  
Old 09-19-2005, 03:04 PM   #3 (permalink)
Account Suspended
Join Date: Aug 2005
Posts: 379
clowesy is a jewel in the roughclowesy is a jewel in the roughclowesy is a jewel in the rough
 



I use echo("string"); too because some guy proved that echo is something like 0.01 ms faster then print.
clowesy is offline  
Old 09-19-2005, 03:07 PM   #4 (permalink)
DNOA Certified Seller
 
RegFee's Avatar
Join Date: Apr 2005
Location: Arizona
Posts: 3,680
RegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond reputeRegFee has a reputation beyond repute
 


Third World Education Third World Education Save The Children Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health Baby Health
I use echo because that's what this "Learn PHP5 in 5 seconds" book told me to use.
__________________
Nombrex.com
RegFee is offline  
Old 09-19-2005, 03:07 PM   #5 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



i use echo("") because it sounds cooler than print lol.
nasaboy007 is offline  
Old 09-19-2005, 03:08 PM   #6 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Quote:
.01 milliseconds faster than print lol
That's because print() returns true or false.
mholt is offline  
Old 09-19-2005, 03:09 PM   #7 (permalink)
NamePros Regular
Join Date: May 2005
Location: Northern Ireland
Posts: 756
aaronfalloon has a spectacular aura aboutaaronfalloon has a spectacular aura about
 



echo is what I use
aaronfalloon is offline  
Old 09-19-2005, 03:27 PM   #8 (permalink)
NamePros Regular
 
dkin69's Avatar
Join Date: May 2005
Posts: 358
dkin69 has a spectacular aura aboutdkin69 has a spectacular aura about
 



I use echo '';

Is that bad ???
dkin69 is offline  
Old 09-19-2005, 03:32 PM THREAD STARTER               #9 (permalink)
Account Closed
 
axilant's Avatar
Join Date: May 2004
Location: /etc/passwd
Posts: 2,178
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
 

Member of the Month
July 2005

Alright,

echo IS faster than print. But!

Heres why:

echo is 4 characters (4 bytes)

print is 5 characters (5 bytes)

That difference would only matter on a system below a 1ghz processor hell, its hardly noticable!

The ONLY difference is 1byte of space... so even 1milisecond... heh thats not bad cause i only have 3 print statements per file execution.

PHP Code:
$cls[func]->head(); //has print inside this function
????: NamePros.com http://www.namepros.com/programming/125063-when-programming-php-do-you-use.html

print $output;

$cls[func]->foot(); //has print inside this function 
Originally Posted by compuXP
That's because print() returns true or false.
Since when?

http://php.net/print

Always returns true. Or 1. Its a language constructor
axilant is offline  
Old 09-19-2005, 03:37 PM   #10 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
just a note to those using echo("") as per the php manual you do not need to use parentheses with it echo "" will work perfectly fine.

I personally use echo "" as it is what I have just got used to doing.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 09-19-2005, 03:45 PM THREAD STARTER               #11 (permalink)
Account Closed
 
axilant's Avatar
Join Date: May 2004
Location: /etc/passwd
Posts: 2,178
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
 

Member of the Month
July 2005

Originally Posted by filth
just a note to those using echo("") as per the php manual you do not need to use parentheses with it echo "" will work perfectly fine.
????: NamePros.com http://www.namepros.com/showthread.php?t=125063

I personally use echo "" as it is what I have just got used to doing.
Lol,

When i was "learning" php, i started using echo... but when i asked for help on a forum, the people would change it from echo to print when they replied... no clue why :-/ So i said the hell with it and started using print lol
axilant is offline  
Old 09-19-2005, 03:49 PM   #12 (permalink)
NamePros Regular
Join Date: Aug 2005
Posts: 214
slantednet is on a distinguished road
 



Originally Posted by axilant
Alright,

echo IS faster than print. But!

Heres why:

echo is 4 characters (4 bytes)

print is 5 characters (5 bytes)

That difference would only matter on a system below a 1ghz processor hell, its hardly noticable!
????: NamePros.com http://www.namepros.com/showthread.php?t=125063

The ONLY difference is 1byte of space... so even 1milisecond... heh thats not bad cause i only have 3 print statements per file execution.
BUZZ... Try again. With 32 bit word lengths common for today's processors (64 bit for tomorrow) I doubt this is a concern. There should be no difference processing that "additional" character...

It does however, take additional time to process the return value (1), but very negligble. It's really a moot issue, use what you feel comfortable with.

And who uses multiple echo/print's per page anyways?
__________________
OnlineGames.net
slantednet is offline  
Old 09-19-2005, 05:19 PM   #13 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



echo "";

for me
__________________
Can't wait to be out of this forsaken business. Getting close! :)
moondog is offline  
Old 09-19-2005, 07:47 PM   #14 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Meh, echo ""; Is what I use.
Eric is offline  
Old 09-20-2005, 03:30 PM   #15 (permalink)
NamePros Member
 
Icespadez's Avatar
Join Date: Apr 2005
Location: Boston, MA
Posts: 26
Icespadez is an unknown quantity at this point
 



echo '';

echo because a return value is not needed
single quotes because variable interpolation BAD
Icespadez is offline  
Old 09-20-2005, 04:43 PM   #16 (permalink)
A Wealth of Knowledge
 
stscac's Avatar
Join Date: Aug 2004
Posts: 3,809
stscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud of
 



PHP Code:
<?
????: NamePros.com http://www.namepros.com/showthread.php?t=125063
// Prepare yourself
echo"You should always use echo, because I do";
?>
-Steve
stscac is offline  
Old 09-20-2005, 04:53 PM   #17 (permalink)
Munky Designs
Join Date: May 2005
Posts: 996
Albino is a jewel in the roughAlbino is a jewel in the roughAlbino is a jewel in the rough
 



echo ""; for me

im just used to it, and i have no reason to need the true or false most of the time.

and "And who uses multiple echo/print's per page anyways?"

I do?
Albino is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: Getting started with PHP (The Basics) deadserious Webmaster Tutorials 60 11-17-2007 12:35 PM
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 10:09 AM
Professional PHP & MySQL programming! CreativeLogic For Sale / Advertising Board 0 06-07-2004 09:26 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:04 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger