English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
print_r() The function is used to print variables in a more easily understandable form.
PHP version requirement: PHP 4, PHP 5, PHP 7
bool print_r ( mixed $expression [, bool $return ] )
Parameter description:
$return if set to true Only returns a value, which is a string message that is easy to understand.
<?php $a = array('a' => 'apple', 'b' => 'banana', 'c' => array('x', 'y', 'z')); print_r($a); ?>
The output is:
Array ( [a] => apple [b] => banana [c] => Array ( [0] => x [1] => y [2] => z ) )
Set the $return parameter:
<?php $b = array('m' => 'monkey', 'foo' => 'bar', 'x' => array('x', 'y', 'z')); $results = print_r($b, true); // $results contains the output of print_r ?>
The above information does not produce any output because the output is assigned to the $results variable.