NameSilo

When programming php do you use....

SpaceshipSpaceship
Watch

Print or echo?

  • This poll is still running and the standings may change.
  • print

    votes
    11.1%
  • echo

    15 
    votes
    83.3%
  • What are you even talking about?

    vote
    5.6%
  • This poll is still running and the standings may change.

axilant

Account Closed
Impact
28
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 ^^
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
echo("string");

is my format.
 
0
•••
I use echo("string"); too because some guy proved that echo is something like 0.01 ms faster then print.
 
0
•••
I use echo because that's what this "Learn PHP5 in 5 seconds" book told me to use. :)
 
0
•••
i use echo("") because it sounds cooler than print lol.
 
0
•••
.01 milliseconds faster than print lol
That's because print() returns true or false. ;)
 
0
•••
echo is what I use
 
0
•••
I use echo '';

Is that bad ??? :sick:
 
0
•••
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:
$cls[func]->head(); //has print inside this function

print $output;

$cls[func]->foot(); //has print inside this function

compuXP said:
That's because print() returns true or false. ;)

Since when?

http://php.net/print

Always returns true. Or 1. Its a language constructor
 
0
•••
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.
 
0
•••
filth said:
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
 
0
•••
axilant said:
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?
 
0
•••
echo "";

for me
 
0
•••
Meh, echo ""; Is what I use. :)
 
0
•••
echo '';

echo because a return value is not needed
single quotes because variable interpolation BAD
 
0
•••
PHP:
<?
// Prepare yourself
echo"You should always use echo, because I do";
?>

-Steve
 
0
•••
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?
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back