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.
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';
'href' will redirect to the specific page when it has clicked or triggered.
'include' is used to get the code from the another file and place it on the called file to use functions and variables