print_r
Syntax
bool print_r ( mixed expression [, bool return] )
Popis
Príkaz jazyka PHP
Prints human-readable information about a variable
Poznámka: The return parameter was added in PHP 4.3.0
print_r() displays information about a variable in a way that's readable by humans. If given a string, integer or float, the value itself will be printed. If given an array, values will be presented in a format that shows keys and elements. Similar notation is used for objects. print_r() and var_export will also show protected and private properties of objects with PHP 5, on the contrary to var_dump.
Remember that print_r() will move the array pointer to the end. Use reset to bring it back to beginning.
Príklad
<pre>
<?php
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print_r ($a);
?>
</pre>
/*Výsledok:
<pre>
Array
(
[a] => apple
[b] => banana
[c] => Array
(
[0] => x
[1] => y
[2] => z
)
)
</pre>
*/
<?php
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print_r ($a);
?>
</pre>
/*Výsledok:
<pre>
Array
(
[a] => apple
[b] => banana
[c] => Array
(
[0] => x
[1] => y
[2] => z
)
)
</pre>
*/
Pozri aj
ob_start, var_dump a var_export