0
<?php
    header("Content-type: text/javascript");
    include("header.php");
?>
<head>

<script type="text/javascript" src="header.php"></script>

</head>

I'm trying to include a PHP (header & footer) file in an HTML file.

The reason it needs to be HTML is this is a content provider that hosts the content and they've put a restriction on the number of characters that can be in the header (as they host it). Any ideas?

4
  • What you have tried? Commented Dec 22, 2014 at 6:37
  • server has to be set to compile php for html extension. Can't see why any host would need to restrict head tag. That doesn't make any sense. Are you sure they mean head tag and not request header? Commented Dec 22, 2014 at 6:39
  • how m include a php file in javascript...??? Commented Dec 22, 2014 at 6:45
  • @AnulekhaThakur you want to include PHP in HTML? does not make sense. You most likely askng the wrong question Commented Dec 22, 2014 at 6:52

2 Answers 2

3

You can not include php in a html page, as php generates html but html can not generate php. So you can try ajax method to include php instead on page load try calling a javascript function which will call the php file.

Sign up to request clarification or add additional context in comments.

Comments

0

window.location.assign("header.php"); by this method you can add php file but only in php page..not with html.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.