I have a variable on my site called $basePath which is set as:
$basePath = '/Systems/dgw/';
I am using it on all my css, js and images tags as so (shortened for better visibility):
<link href="<?php echo $basePath; ?>include/assets/css/bootstrap.min.css">
I have no problem with those includes and they work fine in wherever file and in whatever folder I am.
I have a certain included page which has the following line:
<img src="<?php echo $basePath; ?>images/new_logo.png" alt="logo"/>
And the image shows just fine. The line after it states:
<?php include($basePath.'include/assets/common/topMessages.php');?>
But the include doesn't happens. When I try it like this:
<?php include('../../include/assets/common/topMessages.php');?>
It works.
Anybody has any idea what could be wrong?
echo
does not include anything …www.example.com/
is the root of your website) and the root of a (unix) filesystem. The webroot is mapped to a path in the filesystem; oftenwww.example.com/
is mapped to something like/var/www/example.com/http_docs/
. Your webserver automatically translates any requests for/a/b/c
to/var/www/example.com/http_docs/a/b/c
. However when you include a file via PHP, the webserver is not asked to translate the path, and as such it looks for/a/b/c
in your filesystem, which obviously does not exist.