user
user

Reputation: 9

does it matter which file extension I use for files I call?

just wondering if it matters much which file extension you use for files you're calling into your webpage

For example, I've used a .php file for my navbar like so, and called it like:

<!-- Navbar -->
<?php 
   $path = $_SERVER['DOCUMENT_ROOT'];
   $path .= "/navbar.php";
   include_once($path);
?>

Theres no actual php in the navbar.php file, the navbar file looks like this:

<link rel="stylesheet" href="/styles/navbar.css" type="text/css" /> <!-- navbar styles -->

<ul id="nav">
    <li><a href="/index.php">Home</a></li>
    <li><a href="/page2/">Page 2</a></li>
    <li><a href="/page3/">Page 3</a></li>
</ul>

All works okay, just wondering if it's better practice to call them as .html files or something

Upvotes: 0

Views: 125

Answers (1)

julienhaversano
julienhaversano

Reputation: 446

It won't hurt anyone, you can include a .html file too. So it's really up to you.

Upvotes: 1

Related Questions