HTML within d HTML

Asked

Viewed 70 times

1

I have a doubt here.

I have the following HTML code:

<html>

    <head>

        <?php

    $logado =  'my name';

    ?>

<link rel="stylesheet" type="text/css" href="cabecalho.css"/>

<nav id="menu">
    <ul>
        <yp><?php echo '<p>'.$logado.'</p>'; ?></yp>
        <li><a href="/projetos/index.php">Home</a></li>
        <li><a href="/projetos/historico.php">Histórico</a></li>
        <li><a href="#">Em breve</a></li>
        <li><a href="#">Em breve</a></li>
        <li><a href="#">Em breve</a></li>
    </ul>
</nav> 
  </head>
  <body>
  </body>
</html>

As you can see I’m calling the page features by a Css file

I was wondering if it’s possible to assemble a file that contains

<nav> 
<ul>
        <yp><?php echo '<p>'.$logado.'</p>'; ?></yp>
        <li><a href="/projetos/index.php">Home</a></li>
        <li><a href="/projetos/historico.php">Histórico</a></li>
        <li><a href="#">Em breve</a></li>
        <li><a href="#">Em breve</a></li>
        <li><a href="#">Em breve</a></li>
    </ul>
</nav> 

and that I insert into the page in a similar way with css?

Type:

<html>

    <head>

        <?php

    $logado =  'my name';

    ?>

<link rel="stylesheet" type="text/css" href="cabecalho.css"/>

<link chamar 'nav' aqui dentro/> 
  </head>
  <body>
  </body>
</html>

Thank you!

  • I could not understand what you want, could explain better?

  • How confusing. Nothing made much sense, but who knows would be something that the include of PHP resolvesse?

2 answers

4


Header.php

<nav id="menu">
    <ul>
        <yp><?php echo '<p>'.$logado.'</p>'; ?></yp>
        <li><a href="/projetos/index.php">Home</a></li>
        <li><a href="/projetos/historico.php">Histórico</a></li>
        <li><a href="#">Em breve</a></li>
        <li><a href="#">Em breve</a></li>
        <li><a href="#">Em breve</a></li>
    </ul>
</nav>

Now in the files you want to include use

<?php
   require("Header.php");
?>
  • That’s exactly what it was, thank you very much Rafael

2

If I understand correctly, do the following:

Create a. php file containing all your Nav and call this file where you want using php include or require method.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.