Include PHP file into HTML file
html, include, php, require
Solution
In order to get the PHP output into the HTML file you need to either
- Change the extension of the HTML to file to PHP and include the PHP from there (simple)
- Load your HTML file into your PHP as a kind of template (a lot of work)
- Change your environment so it deals with HTML as if it was PHP (bad idea)
Problem
I'm working on a project that may have to change the same content on all html pages. So I figured I would create a php file and only have to change that so it changes on all pages over the web. The files are saved as: ``` index.html number.php ``` EXAMPLE: ------------------------(HTML FILE)---------------------------- ``` <html> <head> <title>Home</title> </head> <body> <h1>Phone Number</h1> <?php include('number.php') ?> </body> </html> ``` ------------------------(PHP FILE)---------------------------- ``` <?php echo 4895553268; ?> ``` What could I do without changing the file extension of all my html's into php. I've found that works but I would like to only change the code in the html page. I've tried include require tags and that didn't work so I tried script tags and can't seem to make it work right.