dirname(): add warning about risk of infinite loop

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>

Closes GH-1005.
This commit is contained in:
Juliette 2021-11-08 13:20:57 +01:00 committed by GitHub
parent 41c8533ff5
commit 67ca0d930c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,6 +82,25 @@
<parameter>path</parameter> with any trailing
<literal>/component</literal> removed.
</para>
<caution>
<para>
Be careful when using this function in a loop that can reach the
top-level directory as this can result in an infinite loop.
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
dirname('.'); // Will return '.'.
dirname('/'); // Will return `\` on Windows and '/' on *nix systems.
dirname('\\'); // Will return `\` on Windows and '.' on *nix systems.
dirname('C:\\'); // Will return 'C:\' on Windows and '.' on *nix systems.
?>
]]>
</programlisting>
</informalexample>
</para>
</caution>
</refsect1>
<refsect1 role="changelog">