Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't get PHP include keyword to work
    primarykey
    data
    text
    <p>I'm learning PHP and have just discovered how handy the include keyword is, and have started using it on one of the sites I built for the company I work for.</p> <p>Now the site I'm applying this to uses Perch CMS for sections of the website, and the Perch blog extension.</p> <p>I've got the inlclude's working on all files located in the root directory, but one of the files is a Perch CMS blog template, that's located a couple of subdirectories in and the PHP include will not work in this file.</p> <p>The directory of the files I'm trying to include are <strong>../inc/</strong>.</p> <p>The directory of the Perch blog template with the include that <em>doesn't work</em> is <strong>../perch/templates/blog/</strong>.</p> <p><strong>[EDIT]</strong> Sorry I also forgot to mention something which might be important, the file I'm using this include in is used by Perch CMS as a template for how to display the blog posts, it's a regular .html file (although I have a line in my .htaccess file that allows php to be executed in .html files).<strong>[/EDIT]</strong></p> <p>I'm using wamp and in my <strong>www</strong> directory I have multiple folders each acting as a root directory for different projects, this is set up and working using <strong>projectName.localhost</strong> as the address. For example one of them is called <strong>f3racing</strong> and the address is <strong>f3racing.localhost</strong> and the folder structure is <strong>wamp/www/f3racing/</strong>.</p> <p>In all the other files (located in the root directory) this works:</p> <pre><code>&lt;?php include("inc/header.php"); ?&gt; </code></pre> <p>I have tried these:</p> <pre><code>&lt;?php include("../../../inc/header.php"); ?&gt; &lt;?php include($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php"); ?&gt; &lt;?php include($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php"); ?&gt; &lt;?php include($_SERVER["DOCUMENT_ROOT"] . "/f3racing/inc/header.php"); ?&gt; &lt;?php include( $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/inc/header.php"; include_once($path); ); ?&gt; </code></pre> <p>I'm completely stumped as to what to do nest to get this working, should one of these work under normal circumstances? What I mean by that is if I <em>wasn't</em> using Perch CMS would these work?</p>
    singulars
    1. This table or related slice is empty.
    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. 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