I am not understanding when my main website page should be index.php
and not index.html
and what's the difference between the two.
And in case if it's index.php
, how to manage with the javascipt code.
Thank you.
I am not understanding when my main website page should be index.php
and not index.html
and what's the difference between the two.
And in case if it's index.php
, how to manage with the javascipt code.
Thank you.
my main website page should be index.php and not index.html
In a simple web server configuration, if you request a URL which maps onto a directory, then the server will look inside that for an index document.
It will do this by comparing the files in the directory to a list of possible index document names which often include index.html
and index.php
.
It checks them in the order of its list and stops when it finds a match.
Adjacent to this, such servers are typically configured to serve .html
files as static files and to execute .php
files as PHP and serve the result.
And in case if it's index.php how to manage with the javascipt code.
Generating HTML from PHP instead of a static file has absolutely no bearing on how client-side JavaScript is managed.
If you're talking about server-side JS, then you probably don't want to be using PHP at all.
index.extension
is the main trigger file which can be .html, .php or other extensions.
in case of server end programming or you are using PHP language then trigger file should be index.php
while for only html content you can go with index.html
Regarding, adding javascript in index.php file, it could be like
<?php
echo "I am here in PHP code";
?>
<script>
alert("I am here in javascript");
console.log("here in console");
</script>
<?php
echo "I am here ending code";
?>