Problem with require() when using a fully qualified URL
<p>So, my code was using relative paths, but running into some problems with common files which could be include/required from different directory levels.</p>

<p>Absolute paths are more efficient anyway, right? So, I changed all include/require to absolute paths, using <code>require_once('http://' . $_SERVER['HTTP_HOST'] . 'file_name.php');</code></p>

<p><code>$_SERVER['HTTP_HOST']</code> is correct, isn't it? It seemed so when I googled. </p>

<p>That required me to set 'allow_url_include=on` in php.ini and restart Apache.</p>

<p>So, now I have a situation that looks something like this (simplified example):</p>

<p>File2.php contains</p>

<pre><code>&lt;?php
   function hello()
   {
     echo 'hello&lt;br&gt;';
   }
?&gt;
</code></pre>

<p>and if file1.php contains</p>

<pre><code>&lt;?php
   require_once('file2.php');    
   hello();
?&gt;
</code></pre>

<p>then I see the expected output "hello", <strong>but</strong> if I change that line to   </p>

<pre><code>   require_once('http://' . $_SERVER['HTTP_HOST'] . '/file2.php');
</code></pre>

<p>Then I get "Fatal error: Call to undefined function hello() in C:\xampp\htdocs\file1.php"</p>

<p>(I guess that the reference to c:\xammp\httdos came from Xdebug, because PhpInfo shows HTTP_HOST    localhost)</p>

<p>Anyway, that's a long post to say that I am missing some simple point and to ask what it is.</p>
