HTML Templates — php?

前端 未结 4 1524
时光说笑
时光说笑 2021-02-05 23:20

So, I\'m making a site about WWI as a school assignment, and I want this to appear in every document:





    <         


        
4条回答
  •  无人共我
    2021-02-06 00:01

    Create the template file as a single file, exactly you have it already, but printing PHP variables in the places where you want content.

    eg:

    ....
    
    ....

    Then write a PHP function as follows:

    
    

    Now you can load your page content into the template simply by calling the function and passing the content into it for each page.

    So, for example, 1914.php could look like this:

    
    

    Congratulations. You now have a working (albeit very simple) template system. Add more variables / placeholders to your template as required.

提交回复
热议问题