I am developing a web page and I want to make a header that will be in several of the web pages, but I do not know what method I could use and that it would be effective, I tried to do it with a include
, but I get the following error:
Warning: include(\Jomar\users_control\views\header\header.html): failed to open stream: No such file or directory in C:\xampp\htdocs\Jomar\users_control\views\control_assistance\index.php on line 180
Warning: include(): Failed opening '\Jomar\users_control\views\header\header.html' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\Jomar\users_control\ views\control_assistance\index.php on line 180
So if anyone has a more efficient method to do what I want, or a way to fix my problem, please help me.
Here I do theinclude
<?php
include '/Jomar/users_control/views/header/header.html';
?>
Here you can see the html
open with the url
here the directory
It seems you are wrongly accessing the header.html file, try this:
I'm going to give you an example of how
include
con worksPHP
, then you adapt it to your structure... If your project is called Jomar and the filePHP
is located at the root of this directory, it would be:include '/users_control/views/header/header.html';
Assuming my project is called inclusion : at the root of the directory, I put my files
header.html
andfooter.html
. Additionally, I have a directory called view that contains the fileprueba.php
andotro.php
... the files contain the following lines of code:header.html
footer.html
test.php
other.php
I had to search a lot and it is so far the only thing that has worked for me, the method is with
jquery
, with whichload()
I placed the labels<header></header>
and with the$(selector)
ofjquery
I pointed to theheader
and did theload()
and that's it, he loaded it there, he left the example hereThanks for the help, cheers!
It depends on how you want to bring the data, if it is from a file, it would be that simple.
you can use iframes in the main file and put in the src property the path of the php and html you want to include
adding-----
you want the header to be displayed on all your pages so you can create an iframe for the header on all your pages and to call the content of your header you just put the path of your file either html or php, why the "require" is only used to import php code, it does not work with HTML, and with the iframe if you can call an HTML several times