I just started creating a website at my home.
Absolutely, I must have these two pages to finish my website rapidly:- footer.php
, header.php
.
So I created those pages & put some contents. Also created an index page as index.php
inside the htdocs
folder.
Then I did include the header
& footer
pages inside the index.php
page by using these following codes.
<?php include 'header.php'; ?>
<?php include 'footer.php'; ?>
Undoubtedly, they worked fine without any trouble.
Then I created a directory as account
inside the htdocs
.
Now I've a login.php
page inside the account
directory (/account/login.php
).
Repeatedly I used those same codes to include the header
& footer
in the login page. But they didn't work! I saw nothing is happening. If I create the login.php
page inside of the htdocs
folder (not in htdocs/account/
), so it works.
So, how can I include them while the login page is in account
directory?
I think it's a file path problem,you can use this code:
<?php include '../header.php' ?>
<?php include '../footer.php' ?>
Load the file of the first level directory。