How can i get the content between ?> and <?p

2019-05-10 13:41发布

问题:

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());
?>

回答1:

Use output buffering:

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


标签: php oop xhtml