Keeping HTML files separated from the PHP files (template based)

后端 未结 5 1716
情歌与酒
情歌与酒 2021-01-26 00:51

I am trying to keep all the PHP files separated from the HTML files. Sort of a template based project but without using any template engines as they ar

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-26 01:29

    You need to use the extract() function in PHP to get this sorted out. It will then start working as a Controller - View architecture that you are looking for.

    For example:

    
    

    Then directly use $product_list in the view section. This should do it.

    Working example:

    
    

    Create a new File naming it workingExampleView.php:

    
    
        
    
    
    

提交回复
热议问题