Vishal
Vishal

Reputation: 6378

PHP Include does not show headers and footers

This is my first question on this site.

I am very new to programming.

I have index.html file at C:/Wamp/WWW/AddressBook/Index.html and the header.html and footer.html files are located at C:/Wamp/WWW/AddressBook/Includes/

Now I am trying to include these files in my index.html

For Header

<?php include 'Includes/Header.html'; ?>

and for footer

<?php include 'Includes/Footer.html'; ?>

But none of both header and footer are showing up when i open index.html in my browser.

Upvotes: 4

Views: 3102

Answers (3)

Jonast92
Jonast92

Reputation: 4967

Try the

require('url');

function instead, with the () around it:

<?php require('Includes/Header.html'); ?>
<?php require('Includes/Feader.html'); ?>

Also make sure that your folder is actually Includes with an uppercase I and make sure that your Header and Footer are also uppercase in reality.

I really recommend NOT using uppercases in folders and file names; it become way more messier. An exception would be for CLASSES, functions and files should (to avoid mistakes) start with a lowercase but classes should start with an upper-case.

Back to require:

The website should crash if the required file is not found, so you can make sure that you're actually requiring the particular file.

If this doesn't work then you probably have to check into your PHP configurations. If you're not using the project localhost then you should consider changing a web-service, unless you can contact the service provider or modify it on your own.

Upvotes: 0

Osvaldo Costa
Osvaldo Costa

Reputation: 128

You can´t use PHP code in *.html files. You must use *.php instead.

Upvotes: 2

Shikiryu
Shikiryu

Reputation: 10219

Do your Apache understand .html as php file?

If not, rename your index.html to index.php.

Upvotes: 6

Related Questions