-2

I decided to build a booking calendar and embed it to my website. But I don't know how to include it in the html file. I tried the <?php ?> tag but it doesn't display at all. I looked around and found this htaccess file thing. How do I generate it? Is it a way to use my php code without this?

Here is what included in my big html file (I did not include other html here)

<!DOCTYPE html>
<hmtl>
    <head>
    </head>
    <body>
        <?php
        include 'calendar.php';
        $calendar = new Calendar();

        echo $calendar->show();
        ?>
    </body>
</html>

I used sublime text edit and there is no "color" on the key words meaning it is not recognizing the php tag.

Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
Kat
  • 37
  • 1
  • 2
  • 10
  • what is your file saved as ? – TopCheese Feb 24 '17 at 21:05
  • I'm afraid this question is too broad for SO's Q&A format. There are too many things here to easily address in a single answer, and there's not enough information for us to know what's going wrong. I'd really recommend finding a tutorial on setting up a web application server to run PHP instead of putting a question here. When you run into a more specific problem you're more likely to find a good answer here. – AmericanUmlaut Feb 24 '17 at 21:06
  • I also use sublime, that means your file is not saved with .php ext – Masivuye Cokile Feb 28 '17 at 09:26

1 Answers1

0

Place the php code of the calendar in a file and save it as say, calendar.php and then add the following line in the pages where you want the calendar to appear in:

<?php include("calendar.php"); ?>

N.B. Make sure to replace the file extension of all your html files with .php extension instead of the .html extension.

For example: index.html should be index.php

AndrewL64
  • 15,794
  • 8
  • 47
  • 79