PHP Include does not show headers and footers

This is my first question on this site.

I am very new to programming.

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

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

For title

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

and for footer

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

But none of the headers and footers appears when I open index.html in my browser.

+4
source share
3 answers

You cannot use PHP code in * .html files. You should use * .php instead.

+2
source

Does your Apache understand .html as a php file?

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

+6
source

Try

 require('url'); 

and with () around it:

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

Also make sure that your folder actually includes uppercase i and make sure that the header and footer are also uppercase in reality.

I really recommend NOT using uppercase in folders and file names; he becomes more merciless. An exception will be for CLASSES, functions and files must (to avoid errors) begin with a lowercase letter, but classes must begin with an uppercase.

Return to requirement:

A website should crash if the required file is not found, so you can make sure that a specific file is actually required.

If this does not work, you will probably have to check your PHP configurations. If you are not using a local project project, you should consider changing the web service if you cannot contact the service provider or change it yourself.

0
source

All Articles