Aditya Christianto Aditya Christianto - 5 months ago 14
CSS Question

Is the href="" function the same as include?

I want to ask you something about

href
in HTML and
include
in PHP. What is the difference between
href
and
include
, they both refer to a file path? When I type
<link rel='stylesheet' href='style/style1.css' />
it means that "you can find
style.css
file at folder named
style
at your current position and so on for the include. If you can be more specific I will appreciated it.

Answer

href is not a file path, it's a URL, you use it to direct to another page.

include in PHP actually includes a separate file at that point in the page. Let's say you're building a php flat file site. Your header and footer are always the same but the pages change. You could include the header and footer as separate files instead of typing their code into each page.

<?php
  include 'header.php';
  //the rest of your page code goes here.
  include 'footer.php';