include is only inserted after the <body>, and would like it to be included earlier

Asked

Viewed 294 times

-1

I use a file called head.php to add meta tags to each page more easily! However include is only included after the body, when in fact I need you to stay before the body!

Codebase: ........................................... inserir a descrição da imagem aqui

Base code of the head.php page inserir a descrição da imagem aqui

So stay in the browser: inserir a descrição da imagem aqui

  • 1

    This spacing and quotation marks are weird. Even your código base is tabulating wrong. You are using some template engine?

  • 1

    Do you have other includes on the page? Content of head.php is just what you showed? no more lines up or down?

  • There’s nothing!! That’s exactly it! so much that I took print

  • I do not understand why it is to close, if there is still no solution.

2 answers

0


I didn’t quite understand your doubt, but follow an example:

<html>
   <head>
      <?php include "metas.php"; ?>
   </head>
   <body>
     ...
   </body>
</html>
  • I do just that! only it’s not right!

  • @Ivanveloso adds his code to the question, so we can help you.

  • ready! I added images! To see exactly what happens!

  • 1

    Here are some considerations: Include_once only allows you to include this file once; So, it is worth checking if there is another call to that file in the source; In the head.php file, it is worth checking if its charset is as UTF-8 withou BOOM; If you have Notepad++, open the file and go to the Format menu and click Convert to UTF-8 without BOOM.

-1

Use the file_get_contents together with the echo:

<html>
    <head>
        <?php echo file_get_contents('head.php'); ?>
    </head>
</html>

Browser other questions tagged

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