简体   繁体   中英

PHP template with HTML template

I am in middle of using HTML template and I want to convert it to PHP so it will be easier to manage since multiple files are going to be created.

Is it better to use php class and generate the templates in the pages?

For example:

$Template = new Template();

$Template->page_header();
$Template->tag("open-div");
$Template->search_bar();
$Template->tag("close-div");

or use HTML to generate the same?

I know this question has been bit to death but different people ask questions of different nature. So pardon me if this is a report I just needed a short answer or suggestions about this.

Thanks in advance.

Instead of reinventing the wheel, why don't you use a PHP framework which has all of this functionality already built into it? You can operate your system with OOP and provide your HTML views with PHP variables. Popular frameworks include:

Or, if you really want to retain control over your own code, look into using a template engine like:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM