+ 2
How can you activate php to work for my html website?
I have been writing lots of html, js and css code recently but now i need data storing using php however I haven't gotten the php code to work for my html website as it doensn't seem to be processed. any suggestions of how to make it work?
4 Answers
+ 3
I used XAMPP to initialise a local server so I can test my php code, did you check your web host if their service supports php?
đ»How to use XAMPP in a nutshellđ»
To use XAMPP make sure you dont use index.html but index.php once local server running type in your browser localhost/ ăname of file in XAMPP's htdocs file directoryă
hopefully this helps and your <php? tags will hopefully process
+ 2
Can you be more precise in what do you want obtain?
+ 1
Ok I will try to explain:
My php file doesn't seem to interact with my index file. I've made many websites before however I've never made them with php so my big question I was trying to ask is how do I link php to HTML so I can use php code?
+ 1
You can use include or require.
Include example:
<?php include 'footer.php';?> <-- will try to load your PHP script in HTML. If it fails loading your PHP file, it will just continue loading your HTML file.
Require example:
<?php require 'footer.php';?> <-- Requires your PHP script to load alongside your HTML file else both will fail to load resulting in an error.
Make sure you also specify the directory of your .php file else it won't work.
SOURCE: https://www.php.net/manual/en/function.include.php
Is this what you meant? -If so, hope it works for you.