- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
class TM
{
function TM()
{
$this->startBuffering();
register_shutdown_function(array($this, 'endBuffering'));
}
public function startBuffering()
{
ob_start();
}
public function endBuffering()
{
if(ob_get_level() > 1)
{
$data = ob_get_contents();
ob_end_clean();
$this->insertBufferedContent($data);
echo $data;
}
}
function insertBufferedContent(&$data)
{
if(!empty($this->buffered))
{
foreach($this->buffered as $contentID => $contentData)
{
$search[] = ' <!--'.$contentID.'--> ';
}
$data = str_replace($search, $this->buffered, $data);
}
}
function showBuffered($contentID)
{
if(ob_get_level() > 1)
{
echo '<!--'.$contentID.'-->';
}
}
function setBuffered($contentID, $data)
{
$this->buffered[$contentID] = $data;
}
}
$tm = new TM();