<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Returns an array with the names of included or required files</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.get-include-path.html">get_include_path</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-loaded-extensions.html">get_loaded_extensions</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.get-included-files" class="refentry"> <div class="refnamediv"> <h1 class="refname">get_included_files</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">get_included_files</span> — <span class="dc-title">Returns an array with the names of included or required files</span></p> </div> <div class="refsect1 description" id="refsect1-function.get-included-files-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><strong>get_included_files</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Gets the names of all files that have been included using <span class="function"><a href="function.include.html" class="function">include</a></span>, <span class="function"><a href="function.include-once.html" class="function">include_once</a></span>, <span class="function"><a href="function.require.html" class="function">require</a></span> or <span class="function"><a href="function.require-once.html" class="function">require_once</a></span>. </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.get-included-files-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an array of the names of all files. </p> <p class="para"> The script originally called is considered an "included file," so it will be listed together with the files referenced by <span class="function"><a href="function.include.html" class="function">include</a></span> and family. </p> <p class="para"> Files that are included or required multiple times only show up once in the returned array. </p> </div> <div class="refsect1 changelog" id="refsect1-function.get-included-files-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>4.0.1</td> <td> In PHP 4.0.1 and previous versions this function assumed that the required files ended in the extension <em>.php</em>; other extensions would not be returned. The array returned by <span class="function"><strong>get_included_files()</strong></span> was an associative array and only listed files included by <span class="function"><a href="function.include.html" class="function">include</a></span> and <span class="function"><a href="function.include-once.html" class="function">include_once</a></span>. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.get-included-files-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-489"> <p><strong>Example #1 <span class="function"><strong>get_included_files()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// This file is abc.php<br /><br /></span><span style="color: #007700">include </span><span style="color: #DD0000">'test1.php'</span><span style="color: #007700">;<br />include_once </span><span style="color: #DD0000">'test2.php'</span><span style="color: #007700">;<br />require </span><span style="color: #DD0000">'test3.php'</span><span style="color: #007700">;<br />require_once </span><span style="color: #DD0000">'test4.php'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$included_files </span><span style="color: #007700">= </span><span style="color: #0000BB">get_included_files</span><span style="color: #007700">();<br /><br />foreach (</span><span style="color: #0000BB">$included_files </span><span style="color: #007700">as </span><span style="color: #0000BB">$filename</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$filename</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> abc.php test1.php test2.php test3.php test4.php </pre></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.get-included-files-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Files included using the <em>auto_prepend_file</em> configuration directive are not included in the returned array. </p> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.get-included-files-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.include.html" class="function" rel="rdfs-seeAlso">include</a> - include</span></li> <li class="member"> <span class="function"><a href="function.include-once.html" class="function" rel="rdfs-seeAlso">include_once</a> - include_once</span></li> <li class="member"> <span class="function"><a href="function.require.html" class="function" rel="rdfs-seeAlso">require</a> - require</span></li> <li class="member"> <span class="function"><a href="function.require-once.html" class="function" rel="rdfs-seeAlso">require_once</a> - require_once</span></li> <li class="member"> <span class="function"><a href="function.get-required-files.html" class="function" rel="rdfs-seeAlso">get_required_files()</a> - Alias of get_included_files</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.get-include-path.html">get_include_path</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-loaded-extensions.html">get_loaded_extensions</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>