1
我试图修改输出缓冲区的内容。 我得到的东西喜欢这样的:如何修改输出缓冲区?
if($this->page == 'login')
{
$output = ob_get_contents(); // $output is index.html
// have no idea how to modify `$output`
}
和我index.html
:
<html>
<head></head>
</body>
if($usr ==null) include 'login.php';
else include main.php; //`main.php` with header bar and footer bar
// this's where i want to clean and insert my login form (login.php)
</body>
</html>
和login.php
:
<?php
<form>
.....
</form>
?>
我有$output
但我要清理一切,插入的源login.php
进入体内,让每个人都可以看到我的登录表单(有css
作风格的网站)。我搜索了谷歌,只知道如何获得内容,干净和齐平。但我看不出如何修改缓冲区内容。有没有办法修改它?
其实,我做了它在我的index.php,但我认为这是太糟糕的代码。所以我试图ob_get_content希望修改输出。 – Hanata
这应该工作。您的index.html是否被用作所有网页的模板?我已将它更新为{{body}}。您可以使用它来替换来自其他页面的任何内容。 –
哦,真好!你给我一个好主意。非常感谢。 – Hanata