The print_r() function is used to print variables and display them in a more understandable form.
PHP version requirements: PHP 4, PHP 5, PHP 7
bool print_r ( mixed $expression [, bool $return ] )
Parameter description:
$expression: The variable to be printed. If a string, integer or float type variable is given, the variable value itself will be printed. If an array is given, the keys and elements will be displayed in a certain format. object is similar to an array.
$return: Optional, if true, the result will not be output, but the result will be assigned to a variable, if false, the result will be output directly.
$return
will only return a value if set to true , which is an easy-to-understand string information.
The output is:
Array( [a] => apple [b] => banana [c] => Array ( [0] => x [1] => y [2] => z ))
Set the $return
parameter:
There is no output result for the above information, because the output result is assigned to the $results
variable.