EY Posted March 10, 2008 Share Posted March 10, 2008 Why use print_r instead of echo? Are they the same thing? If not what is the difference? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/95480-print_r-vs-echo/ Share on other sites More sharing options...
wildteen88 Posted March 10, 2008 Share Posted March 10, 2008 They are not the same, print_r is to display the contents of an array or object. read the manual on what each do. Quote Link to comment https://forums.phpfreaks.com/topic/95480-print_r-vs-echo/#findComment-488763 Share on other sites More sharing options...
DarkerAngel Posted March 10, 2008 Share Posted March 10, 2008 The only time I ever use print_r is when I want to display all elements of an array, mainly in development and debugging. Quote Link to comment https://forums.phpfreaks.com/topic/95480-print_r-vs-echo/#findComment-488765 Share on other sites More sharing options...
MadTechie Posted March 10, 2008 Share Posted March 10, 2008 print_r — Prints human-readable information about a variable echo — Output one or more strings try this <?php $myArray = array("test", "123"); echo "echo=".$myArray; echo "print_r="; print_r($myArray); ?> Quote Link to comment https://forums.phpfreaks.com/topic/95480-print_r-vs-echo/#findComment-488766 Share on other sites More sharing options...
EY Posted March 10, 2008 Author Share Posted March 10, 2008 Alright thanks for the help. Im still not at arrays but i understand what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/95480-print_r-vs-echo/#findComment-488770 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.