Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No. Using <code>./</code> at the start of your include file name forces it to be searched from the "current directory" as set by your web server (most probably the directory of the initial script, or the DocumentRoot, depending on the webserver).</p> <p>The way to get the behaviour you want depends on the value of your <a href="http://au.php.net/manual/en/ini.core.php#ini.include-path" rel="nofollow noreferrer"><code>include_path</code></a> (which can be modified with <a href="http://au.php.net/set_include_path" rel="nofollow noreferrer"><code>set_include_path()</code></a> if necessary).</p> <p>From the documentation for <a href="http://au.php.net/manual/en/function.include.php" rel="nofollow noreferrer"><code>include()</code></a>:</p> <blockquote> <p>Files for including are first looked for in each <code>include_path entry</code> relative to the current working directory, and then in the directory of current script. E.g. if your <code>include_path</code> is <strong><code>libraries</code></strong>, current working directory is <strong><code>/www/</code></strong>, you included <strong><code>include/a.php</code></strong> and there is include "<strong><code>b.php</code></strong>" in that file, b.php is first looked in <strong><code>/www/libraries/</code></strong> and then in <strong><code>/www/include/</code></strong>. If filename begins with <code>./</code> or <code>../</code>, it is looked for only in the current working directory or parent of the current working directory, respectively.</p> </blockquote> <p>So, if there's no chance that the filename will be found in another directory in the <code>include_path</code> first, you could use <code>include('apple.php')</code>. </p> <p>If there is a possibility that apple.php exists elsewhere, and you want the copy in this folder to be used first, you could either use Matthew's suggestion, and </p> <pre><code>include(dirname(__FILE__).'/apple.php'); </code></pre> <p>or, if you have many files to include from the current directory:</p> <pre><code>old_include_path = set_include_path(dirname(__FILE__)); include('apple.php'); include('orange.php'); include('peach.php'); include('pear.php'); set_include_path(old_include_path); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload