print_r – PHP Reference Book Blog https://phpreferencebook.com/ PHP Reference: Beginner to Intermediate PHP5 Sun, 01 Oct 2017 17:21:19 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.13 Print_r optional parameter correction https://phpreferencebook.com/corrections/print_r-return-parameter/ Wed, 14 Jan 2009 05:21:35 +0000 https://phpreferencebook.com/?p=81 Continue reading Print_r optional parameter correction]]> (pg. 38)

In the book, the print_r() function is described as follows:

print_r($variable)

Output the contents of $variable . Typically used to display the contents of an array.

However, there is also an optional flag for the print_r() function that makes the function return the output rather than printing it to the screen. Therefore, the section of the book should be amended as follows:

print_r($variable [,return])

return – [optional] $boolean default: FALSE, print output
Output the contents of $variable. Typically used to display the contents of an array. If return is set to TRUE, print_r() returns the output rather than displaying it, such as when storing it in a variable.

]]>