我如何才能获得两者之间的内容?和<?php [英] How can i get the content between ?> and <?php

查看:79
本文介绍了我如何才能获得两者之间的内容?和<?php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

get这只是一个个人学习问题.我想检索我的函数$ page-> content_start();之间的所有内容;和$ page-> content_end();如何获得它的最佳方式?我不想包含或回显它,有可能吗?

getThis is just a personal learning question. I want to retrieve all the content between my function $page->content_start(); and $page->content_end(); how is the best way to get it? I don't want to include it or echo it, is it possible?

非常感谢,非常感谢您的建议

Thank you very much, your advices is very appreciated

<?php 

include 'pages/indexpage.class.php';
include 'modules/monmodule.class.php';

$page = new IndexPage();
$mod = new MonModule($page);
$mod->create();

$page->content_start();
?>
<div class="asss_ass"></div>
<span></span>
<?php
$page->content_end();
print_r($page->get_content());
?>

推荐答案

使用输出缓冲 :

ob_start();
?>
<div class="asss_ass"></div>
<span></span>
<?php
$content = ob_get_clean();

这篇关于我如何才能获得两者之间的内容?和&lt;?php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆