mdvignesh Posted January 12, 2012 Share Posted January 12, 2012 whats the diff between echo,print,print_r what's the difference between include(),require,require_once Quote Link to comment https://forums.phpfreaks.com/topic/254880-doubt/ Share on other sites More sharing options...
Muddy_Funster Posted January 12, 2012 Share Posted January 12, 2012 Quote Link to comment https://forums.phpfreaks.com/topic/254880-doubt/#findComment-1306870 Share on other sites More sharing options...
wolfcry Posted January 12, 2012 Share Posted January 12, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/254880-doubt/#findComment-1306874 Share on other sites More sharing options...
Muddy_Funster Posted January 12, 2012 Share Posted January 12, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/254880-doubt/#findComment-1306880 Share on other sites More sharing options...
litebearer Posted January 12, 2012 Share Posted January 12, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/254880-doubt/#findComment-1306884 Share on other sites More sharing options...
Muddy_Funster Posted January 12, 2012 Share Posted January 12, 2012 I feel a more significant difference at this level is that with "print" you can not pass multiple string values into it, unlike "echo". Quote Link to comment https://forums.phpfreaks.com/topic/254880-doubt/#findComment-1306889 Share on other sites More sharing options...
PFMaBiSmAd Posted January 12, 2012 Share Posted January 12, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/254880-doubt/#findComment-1306891 Share on other sites More sharing options...
ManiacDan Posted January 12, 2012 Share Posted January 12, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/254880-doubt/#findComment-1306909 Share on other sites More sharing options...
wolfcry Posted January 12, 2012 Share Posted January 12, 2012 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... Quote Link to comment https://forums.phpfreaks.com/topic/254880-doubt/#findComment-1306915 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.