vrana Sun Feb 13 17:32:44 2005 EDT
Modified files:
/phpdoc/en/language functions.xml
Log:
Recursive functions (spotted by ondra at dynawest.cz)
http://cvs.php.net/diff.php/phpdoc/en/language/functions.xml?r1=1.57&r2=1.58&ty=u
Index: phpdoc/en/language/functions.xml
diff -u phpdoc/en/language/functions.xml:1.57
phpdoc/en/language/functions.xml:1.58
--- phpdoc/en/language/functions.xml:1.57 Sun Feb 13 17:13:07 2005
+++ phpdoc/en/language/functions.xml Sun Feb 13 17:32:44 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.57 $ -->
+<!-- $Revision: 1.58 $ -->
<chapter id="language.functions">
<title>Functions</title>
@@ -130,6 +130,28 @@
<function>func_get_arg</function>, and
<function>func_get_args</function> for more information.
</simpara>
+
+ <para>
+ It is possible to call recursive functions in PHP. However avoid recursive
+ function/method calls with over 100-200 recursion levels as it can smash
+ the stack and cause a termination of the current script.
+ <example>
+ <title>Recursive functions</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+function recursion($a)
+{
+ if ($a < 20) {
+ echo "$a\n";
+ recursion($a + 1);
+ }
+}
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
</sect1>