Note that there are some explanatory texts on larger screens.

plurals
  1. POinclude statement using a variable in the filename
    primarykey
    data
    text
    <p>(Please be patient, this does have something to do with include.) I am waiting for a domain to transfer over and am trying to set it up on the new hosting service ahead of time. I realized that on the old site all the path names were absolute, so all my links on the new host point to pages on the old host. I decided to make them all relative (for future possible moves also). I first did it like this:</p> <p>index.php</p> <pre><code>include ('./header.php'); </code></pre> <p>header.php</p> <pre><code>include "./panel.php"; </code></pre> <p>panel.php</p> <pre><code>Contents of panel. </code></pre> <p>This works, and my page displays:</p> <p>Contents of panel.</p> <p>Then I decided to set a variable for the domain because I want to include this header file from files in subdirectories and I can use the domain variable to make an absolute path. Right now I have a temporary domain name, which I can change later to the real domain name when the transfer comes through. So I changed header.php to:</p> <pre><code>$domain="http://tempdomain.com"; //I can change this after the transfer $panel=$domain."/panel.php"; echo $panel; if ((include $panel) !== 1) { echo "&lt;br&gt;include failed"; } </code></pre> <p>What I get is:</p> <p><a href="http://tempdomain.com/panel.php" rel="nofollow">http://tempdomain.com/panel.php</a><br> include failed</p> <p>I've looked at various sites for include syntax, but I can't find any error in my code. All these files are in the / directory. Any ideas?</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. 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