How to I inject only certain parts of PHP page using PHP

前端 未结 3 1856
醉话见心
醉话见心 2020-12-16 22:19

I know I can include other files using PHP


Now my question is how do I inject only certain parts of \

3条回答
  •  春和景丽
    2020-12-16 22:44

    The easiest (and usual) way is to simply make separate header.php and footer.php files, and access them where you need them. There's no direct support for only loading parts of a file.

    Edit (to respond to your comment on the other answer about using separate functions): Let's say your file.php looks like this:

    
       header content goes here
    
        footer content goes here
    
    

    Then in the page you're calling it into, you can use and to produce the content where you want it.

提交回复
热议问题