1
I’m having trouble including a php code with html on another page using include, in case the code is a menu written in html but with php extension. When having to include the code from the menu.php file in the index.php file, it accuses an error in the.php menu file line 2 of "<". I will post the codes to make it easier to understand the problem. This.php menu is for study purposes only.
File includes/menu.php:
<?php <head>
<title>Construção de interface em HTML e CSS</title>
<meta charset="UTF-8">
<style type="text/css">
@import "estilo/layout.css";
</style>
</head>
<body>
<div id="container">
<header>
<h1>The Door</h1>
</header>
<div id="login">
<ol>
<li><a href="">Login</a>
</li>
</ol>
</div>
<nav>
<ol>
<li><a href="">Principal</a>
</li>
<li><a href="">Faculdade</a>
</li>
<li><a href="">Links</a>
</li>
<li><a href="">Outros</a>
</li>
</ol>
</nav>
<section id="destaque">
<figure>
<img src="imagens/gatostop.jpg">
<figcaption>Gatinhos zueiros</figcaption>
</figure>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Lorem ipsum dolor
sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit amet,
consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</section>
<main>
<section>
<article>
<h3>Título 1</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</article>
<article>
<h3>Título 2</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</article>
</section>
<aside>
<div>Link externo</div>
<div>Conteúdo adicional</div>
<div>Publicidade</div>
</aside>
</main>
<footer>Development by
<h4>Rafael<h4></footer>
</div>
</body>
?>
index.php file:
<?php
include "includes/menu.php";
?>
in his
menu.php
has the tags<?php
and?>
and no codePHP
, you could remove the tags and see if it works.– MeuChapeu
this is the question friend, if I remove the php tag, how will I include my menu in other pages?
– Rafael2F
He’ll call the file
.php
. Or you have to do as @Allan Ramos' reply.– MeuChapeu
@Rafael2f, usually code snippets in PHP (in a file
.php
, obvious) in an HTML structure, not the other way around. That is, you will open the tag<?php
only where you need to use PHP (print a variable on the screen, for example).– Caesar
@Rafael2f do you want to call the menu in another view? You are using some framework?
– GWER
I’m not using framework
– Rafael2F