php-doc-en/reference/var/functions/print-r.xml
Jan Lehnardt d25ec03ae6 - fix return type
#please check the other translations


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@95937 c90b9560-bf6c-de11-be94-00142212c4b1
2002-09-17 08:51:27 +00:00

102 lines
2.7 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/var.xml, last change in rev 1.5 -->
<refentry id="function.print-r">
<refnamediv>
<refname>print_r</refname>
<refpurpose>
Prints human-readable information about a variable
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>print_r</methodname>
<methodparam><type>mixed</type><parameter>expression</parameter></methodparam>
</methodsynopsis>
<simpara>
<function>print_r</function> displays information about a variable
in a way that's readable by humans. If given a <type>string</type>,
<type>integer</type> or <type>float</type>, the value itself will be
printed. If given an <type>array</type>,
values will be presented in a format that shows keys and
elements. Similar notation is used for <type>object</type>s.
</simpara>
<simpara>
Remember that <function>print_r</function> will move the array
pointer to the end. Use <function>reset</function> to bring
it back to beginning.
</simpara>
&tip.ob-capture;
<para>
<informalexample>
<programlisting role="php">
<![CDATA[
<pre>
<?php
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x','y','z'));
print_r ($a);
?>
</pre>
]]>
</programlisting>
</informalexample>
</para>
<para>
Which will output:
<screen>
<![CDATA[
<pre>
Array
(
[a] => apple
[b] => banana
[c] => Array
(
[0] => x
[1] => y
[2] => z
)
)
</pre>
]]>
</screen>
</para>
<note>
<simpara>
Prior to PHP 4.0.4, <function>print_r</function> will continue forever
if given an <type>array</type> or <type>object</type> that
contains a direct or indirect reference to itself. An example
is <literal>print_r($GLOBALS)</literal> because
<literal>$GLOBALS</literal> is itself a global variable that
contains a reference to itself.
</simpara>
</note>
<simpara>
See also <function>ob_start</function>, <function>var_dump</function>,
and <function>var_export</function>.
</simpara>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->