Correctly include php header in all pages

前端 未结 2 753
失恋的感觉
失恋的感觉 2021-01-25 21:23

I would include a php header (mysite.com/header.php) in all the pages from a site.

How to do it properly?

There are relative links:



        
相关标签:
2条回答
  • 2021-01-25 21:32

    Try

    <?php require_once('./header.php'); ?>
    

    And adjust the path as needed, i.e. ../header.

    0 讨论(0)
  • 2021-01-25 21:43

    You can do something like this:

    include($_SERVER["DOCUMENT_ROOT"] . "/header.php");
    
    0 讨论(0)
提交回复
热议问题