PHP Include for HTML?

前端 未结 7 2000
小蘑菇
小蘑菇 2020-12-02 23:22

I have a navigational bar, an image, and a heading that I\'ll be including in every page of my website, so I wanted to use php include to refer to this code in several pages

相关标签:
7条回答
  • 2020-12-03 00:11

    First: what the others said. Forget the echo statement and just write your navbar.php as a regular HTML file.

    Second: your include paths are probably messed up. To make sure you include files that are in the same directory as the current file, use __DIR__:

    include __DIR__.'/navbar.php'; // PHP 5.3 and later
    include dirname(__FILE__).'/navbar.php'; // PHP 5.2
    
    0 讨论(0)
提交回复
热议问题