开发者

What's the best way to automatically print an HTML header and bottom in php?

开发者 https://www.devze.com 2022-12-24 10:24 出处:网络
开发者_Python百科Currently I\'m using: PrintHeader(); /* Page code... */ PrintBottom(); Is there a better way?Any output shouldn\'t be done automatically. As not every script call may return a page

开发者_Python百科Currently I'm using:

PrintHeader();
/* Page code... */
PrintBottom();

Is there a better way?


Any output shouldn't be done automatically. As not every script call may return a page of text. So, you have to call page renderer manually.

So, you can make it with single call CallTemplateRender();
Not a much difference though


Its best to separate your business logic and display code, I typically use a master php page with a variable that includes an inner php page. Something like this:

<html>
<head></head>
<body>
    include($template_file);
</body>
</html

Then my logic page works like this:

//do processing
$set_variables;

$template_file = "inner_file.php";
include("master_template.php");

Of course its a little more involved than that but all of my logic and display is separate so it's easier to manage.

0

精彩评论

暂无评论...
验证码 换一张
取 消