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

落爺英雄遲暮 提交于 2019-12-12 09:46:42

问题


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


来源:https://stackoverflow.com/questions/10840848/how-can-i-get-the-content-between-and-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!