I have this site I'm making. When I include a php file from the same folder it works but when I do
<?php include('/ioanblog/appstore/header.php');?>
it doesn't work or
<?php include('http://www.domain.co.uk/appstore/header.php');?>
that isn't working either.
All the header is holding is a style sheet and Piwik code, it will also hold navigation.
Read the documentation on relative paths.
If a path is defined — whether absolute (starting with a drive letter or \ on Windows, or / on Unix/Linux systems) or relative to the current directory (starting with . or ..) — the include_path will be ignored altogether. For example, if a filename begins with ../, the parser will look in the parent directory to find the requested file.
You are using /ioanblog/…
which is an absolute path. I suspect your site is in /var/www/public_html/ioanblog/…
or /home/user/ioanblog/…
or something similar, not in /ioanblog/…
. You should remove the first /
making it a relative instead of an absolute path. You might have to go "up" to parent directories like ../contents/header.php
or ../../contents/header.php
for the actual file.
As pointed out by brbcoding it should probably be ../../header.php
. But first make sure you understand absolute/relative paths!
You might also want to read up on realpath()
to 'convert' relative paths to absolute paths.
It's hard to say why the include won't work without knowing the folder structure. But you can try it with the absolute path: /home/user/domain/public_html/etc...
try removing the first slash so include('ioanblog/appstore/header.php');
Use <?php include('../../header.php');?>
That's my guess... You don't have an appstore
directory anywhere as far as I can tell.
EDIT: Updated with the correct path... Coming from the libreoffice
directory.