[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


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, 01:56 PM   #1 (permalink)
Account Closed
 
axilant's Avatar
 
Join Date: May 2004
Location: /etc/passwd
Posts: 2,194
0.00 NP$ (Donate)

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


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, 02:03 PM   #2 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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.
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 09-19-2005, 02:04 PM   #3 (permalink)
Account Suspended
 
Join Date: Aug 2005
Posts: 379
385.00 NP$ (Donate)

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, 02:07 PM   #4 (permalink)
DNOA Certified Seller
 
RegFee's Avatar
 
Join Date: Apr 2005
Location: Arizona
Posts: 3,644
285.00 NP$ (Donate)

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.
__________________

RegFee.info - Available Domain Names - NEW DESIGN!
DNWholesaler.com - Domains for Sale

<--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me
RegFee is offline  
Old 09-19-2005, 02:07 PM   #5 (permalink)
Senior Member
 
nasaboy007's Avatar
 
Join Date: Jul 2005
Location: NJ
Posts: 1,112
1,454.30 NP$ (Donate)

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 of


i use echo("") because it sounds cooler than print lol.
nasaboy007 is offline  
Old 09-19-2005, 02:08 PM   #6 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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.
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 09-19-2005, 02:09 PM   #7 (permalink)
NamePros Regular
 
Join Date: May 2005
Location: Northern Ireland
Posts: 747
636.00 NP$ (Donate)

aaronfalloon has a spectacular aura aboutaaronfalloon has a spectacular aura about


echo is what I use
aaronfalloon is offline  
Old 09-19-2005, 02:27 PM   #8 (permalink)
NamePros Regular
 
dkin69's Avatar
 
Join Date: May 2005
Posts: 358
15.75 NP$ (Donate)

dkin69 has a spectacular aura aboutdkin69 has a spectacular aura about


I use echo '';

Is that bad ???
dkin69 is offline  
Old 09-19-2005, 02:32 PM   #9 (permalink)
Account Closed
 
axilant's Avatar
 
Join Date: May 2004
Location: /etc/passwd
Posts: 2,194
0.00 NP$ (Donate)

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


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

print $output;

$cls[func]->foot(); //has print inside this function
Quote:
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, 02:37 PM   #10 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

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, 02:45 PM   #11 (permalink)
Account Closed
 
axilant's Avatar
 
Join Date: May 2004
Location: /etc/passwd
Posts: 2,194
0.00 NP$ (Donate)

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


Quote:
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.

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, 02:49 PM   #12 (permalink)
NamePros Regular
 
Join Date: Aug 2005
Posts: 214
170.00 NP$ (Donate)

slantednet is on a distinguished road


Quote:
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!

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, 04:19 PM   #13 (permalink)
NamePros Regular
 
moondog's Avatar
 
Join Date: Jun 2004
Posts: 476
3,677.00 NP$ (Donate)

moondog is a glorious beacon of lightmoondog is a glorious beacon of lightmoondog is a glorious beacon of lightmoondog is a glorious beacon of lightmoondog is a glorious beacon of lightmoondog is a glorious beacon of light


echo "";

for me
__________________
The mass purge has begun.
moondog is offline  
Old 09-19-2005, 06:47 PM   #14 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
Meh, echo ""; Is what I use.
__________________
Eric is offline  
Old 09-20-2005, 02:30 PM   #15 (permalink)
NamePros Member
 
Icespadez's Avatar
 
Join Date: Apr 2005
Location: Boston, MA
Posts: 26
290.00 NP$ (Donate)

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, 03:43 PM   #16 (permalink)
A Wealth of Knowledge
 
stscac's Avatar
 
Join Date: Aug 2004
Posts: 3,794
47.60 NP$ (Donate)

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:
<?
// Prepare yourself
echo"You should always use echo, because I do";
?>
-Steve
stscac is offline  
Old 09-20-2005, 03:53 PM   #17 (permalink)
Munky Designs
 
Join Date: May 2005
Posts: 997
417.00 NP$ (Donate)

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 05:36 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85