Jump to content
MakeWebGames

Debate


Haunted Dawg

Recommended Posts

Guest Anonymous

Re: Debate

Look at the source to PHP...

Both functions go through the low level standard libc library, so the effect is identical.

Speedwise, if you are concerned, then I'd suggest your need to rethink your ideas. I have (IIRC) one print, one and one echo at the maximum on any page.

Benchmarking is pointless, as almost any system you will create will be cached, so it (for me) comes down to the level of code clarity, something that is sadly lacking here.

Take your pick... echo is a function (yes, I know it doesn't look like it, but look at the LALR parser of PHP), printf and sprintf both call the same inbuilt routines, so the question becomes, just how does echo display information versus printf ... perhaps they use the same mechanism.

Go find out. The source has all the answers.

Link to comment
Share on other sites

  • 3 weeks later...

Re: Debate

 

Speedwise, if you are concerned, then I'd suggest your need to rethink your ideas.

Speed wise it should be irrelevant which one you use... echo is only marginally faster since it doesn't set a return value...

There is a difference in the expression of the command. I think that print can be used as part of a more complex expression where echo cannot.

print() can only take one parameter... whereas, echo without parentheses can take multiple parameters, which get concatenated. So for example

 

   echo  "and a ", 1, 2, 3;   // comma-separated without parentheses
  echo ("and a 123");        // just one parameter with parentheses

print() can only take one parameter:

  print ("and a 123");
  print  "and a 123";

 

Or am I wrong?

Link to comment
Share on other sites

Re: Debate

 

Speedwise, if you are concerned, then I'd suggest your need to rethink your ideas.

Speed wise it should be irrelevant which one you use... echo is only marginally faster since it doesn't set a return value...

There is a difference in the expression of the command. I think that print can be used as part of a more complex expression where echo cannot.

print() can only take one parameter... whereas, echo without parentheses can take multiple parameters, which get concatenated. So for example

 

   echo  "and a ", 1, 2, 3;   // comma-separated without parentheses
  echo ("and a 123");        // just one parameter with parentheses

print() can only take one parameter:

  print ("and a 123");
  print  "and a 123";

 

Or am I wrong?

Print can be used as a function whereas echo cannot.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...