0

I've tryed to setup xampp for 3 hours. Given up with that, having a bit more success with wamp how ever php code isnt compiling.

I have index.htm and header.php in my www folder.

index.htm code:

<?php include('header.php');?>

<body>
    <h1>This is a header</h1>
    <p>this is a paragraph</p>


</body>
</html>

header.php code

<?php
    echo "<!doctype html><html lang='en'><head><title>PAGETITLE</title></head>";
?>

The php code is showing instead of compiling. How do i fix this?

Tchoupi
  • 14,560
  • 5
  • 37
  • 71
Larry
  • 1,231
  • 4
  • 12
  • 18
  • index.htm should be called index.php. โ€“ Rich Bradshaw Mar 31 '13 at 17:24
  • Rename index.htm to index.php โ€“ Tamil Selvan C Mar 31 '13 at 17:24
  • Someone should make note that this is just the *default* behaviour because it's easy enough to have Apache push `.html` extensions through the interpreter. [ยป first SO question in search result](http://stackoverflow.com/questions/11234010/process-specific-htm-page-as-php-on-apache-server) โ€“ Emissary Mar 31 '13 at 19:06

2 Answers2

3

You can't use <?php include('header.php');?> in an HTML (.htm) file so please change that extension to .php and it will work.

swiecki
  • 3,483
  • 3
  • 23
  • 19
user1370510
  • 120
  • 7
1

PHP DOES NOT work, in .html files. It works only in .php files, or .php, .phtml, .php4 .php3, .php5, .phps

samayo
  • 16,163
  • 12
  • 91
  • 106