Reputation: 63
I am trying to use php includes to link one .php file to another. The structure is this:
ROOT
¦
+---templates
¦ ¦
¦ +---footer.php
¦
¦
+---main
¦
+---maps
¦
+---uk
¦
+---map.php
Using <?PHP include "../../../templates/navbar.php"; ?>
the code links absolutely fine.
Using either <?PHP include dirname(__FILE__) . "../../../templates/navbar.php"; ?>
or <?PHP include __DIR__ . "../../../templates/navbar.php"; ?>
gets me absolutely nothing. What am I missing? Thanks.
Upvotes: 2
Views: 5067
Reputation: 3409
__DIR__ doesn't include the trailing /
in directory name, so <?PHP include __DIR__ . "/../../../templates/navbar.php"; ?>
is what you need.
Upvotes: 4