Jump to content

doubt


mdvignesh

Recommended Posts

Echo and print do exactly the same thing, though print is a reminiscent function based off C / C++. Print_r prints the data of a variable (like an array) that's readable, kinda like var_dump and include will not kill the page if the include file is not found whereas require will. If you use include_once, or require_once, that means the server will only include that file once rather than multiple times if you have called it multiple times in your page.

 

Also, go here and search for those terms:

http://php.net/manual/en/index.php

 

 

Link to comment
Share on other sites

Echo and print do exactly the same thing, though print is a reminiscent function based off C / C++. Print_r prints the data of a variable (like an array) that's readable, kinda like var_dump and include will not kill the page if the include file is not found whereas require will. If you use include_once, or require_once, that means the server will only include that file once rather than multiple times if you have called it multiple times in your page.

 

Also, go here and search for those terms:

http://php.net/manual/en/index.php

 

Echo and Print are not exactly the same.

Link to comment
Share on other sites

Echo

Echo uses the format echo "Hello, world";. This simply causes the string “Hello, world” to be sent to the browser (or whatever you are outputting to). Nothing is returned so you cannot use the structure $return = echo("Hello, world");.

 

Print

Print can be used in much the same way as echo, with one difference. You have the ability to use a return value. Print returns the value 1 if successful, so $retval = print("Hello, world"); would set $retval = 1. This can be useful if you are doing something more complex than simply outputting text.

 

PrintF

PrintF goes up a step on print and allows you to format the text prior to output. The formatting strings are described in the manual page for sprintf.

Link to comment
Share on other sites

The moral of the story being, if the OP had simply researched and read the php.net documentation for the basic information he is asking someone else about, he can get the full story from the official source of that information, in much greater detail and accuracy then what he will get in the few 10's or few 100's of words that someone will take the time to write in a forum reply.

Link to comment
Share on other sites

Note, for any newbies coming across this, that instead of reading the manual the OP asked us to do the research for him.  Not only is that bad form, but he immediately received a wrong answer.  Not a completely wrong answer, but an answer wrong enough that it would hamper his understanding of the output functions.

Link to comment
Share on other sites

Yeah, you're right, my answer is off. I originally intended to say "In short, they both basically do the same thing as far as printing output to the browser with the exception of blah, blah blah." My bad.

 

And that's an excellent point ManiacDan regarding relying on forums for "accurate answers" where all one has to do is read the manual. Especially when it comes to having others do the research for them.

 

Because in the end, we all perceive things differently and do things in ways others would not...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.