Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could include it relative to the current directory, like so:</p> <pre><code>require_once(dirname(__FILE__) . '/template.php'); </code></pre> <p>dirname(<strong>FILE</strong>) will translate to the directory of the current script (index.php) and the line above will append '/template.php' resulting in the full path to the template.php side-by-side to the index.php file.</p> <p>I find it best to include files this way vs without a full path to avoid issues with the PHP search path, for example. It's very explicit this way.</p> <p><strong>UPDATE</strong>: I misunderstood the original question. It sounds like template.php isn't copied, only index.php is. So you'll have something that could be like:</p> <pre><code>template/template.php template/index.php (just a template) foo/bar/index.php foo/bar2/index.php </code></pre> <p>Since people can hit the foo/bar/index.php for example without funneling through a central script, you'll have to somehow find the template no matter where you are.</p> <p>You can do this by setting the PHP include_path, for example through a .htaccess on a Apache server:</p> <pre><code>php_value include_path ".:/home/&lt;snip&gt;/template" </code></pre> <p>Then in each index.php you can include template.php and it'll search the current directory first, then try your template directory.</p> <p>You could also compute the relative path when copying the script and put an include in there with the proper number of '..' to get out (e.g. '../../template/template.php'). It's kinda fragile, though.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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