我有一个类似于login.php的HTML文件
<div class="modal fade" id="modal_login" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Login</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12 col-md-8 col-md-offset-2">
<h1 class="text-center login-title">Sign in to Hawiak.nl</h1>
<div class="account-wall">
<img class="profile-img" src="" alt="">
<form class="form-signin" method="post" action="<?php echo $pages->get("/login/")->url; ?>">
<input type="text" name="username" class="form-control" placeholder="Username" required autofocus>
<input type="password" name="password" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">
Sign in</button>
<label class="checkbox pull-left">
<input type="checkbox" value="remember-me">
Remember me
</label>
<a href="#" class="pull-right need-help">Need help? </a><span class="clearfix"></span>
</form>
</div>
<a href="#" class="text-center new-account">Create an account </a>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
但如果我使用这个脚本:
foreach($this->snippets as $key => $snippet){
if(file_exists('snippets/' . $snippet)){
echo 'test';
ob_start();
include('snippets/' . $snippet);
$$key = ob_get_clean();
var_dump($$key);
}else{
//snippet doesn't exist
echo $snippet . ' does not exist!' . '<br />';
}
}
要遍历一个看起来像array('login'=> 'login.php', 'navbar'=> 'navbar.php')
的数组,它只显示以下html:
<div class="modal fade" id="modal_login" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria- hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Login</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12 col-md-8 col-md-offset-2">
<h1 class="text-center login-title">Sign in to Hawiak.nl</h1>
<div class="account-wall">
<img class="profile-img" src="" alt="">
为什么?
最重要的是我如何解决这个问题?
答案 0 :(得分:1)
您致电ob_end_flush()
,
输出缓冲区是可堆叠的,也就是说,当另一个ob_start()处于活动状态时,您可以调用ob_start()。只需确保拨打ob_end_flush()
适当的次数即可。如果多个输出回调函数处于活动状态,则将按嵌套顺序依次对每个输出回调函数进行过滤。
ob_start — Turn on output buffering
此功能将打开输出缓冲。当输出缓冲处于活动状态时,不会从脚本(标头除外)发送输出,而是将输出存储在内部缓冲区中。
可以使用ob_get_contents()将此内部缓冲区的内容复制到字符串变量中。要输出存储在内部缓冲区中的内容,请使用ob_end_flush()。或者,ob_end_clean()将静默地丢弃缓冲区内容。
答案 1 :(得分:1)
您的Sript在$ pages-&gt; get(“/ login /”) - &gt; url行某处崩溃,但我们没有关于该getter的更多信息。
请在吸气器顶部输入一个骰子('line:'。_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _这样你就可以找到错误的行。