tjm/buffermanager
Composer 安装命令:
composer require tjm/buffermanager
包简介
Manager of PHP output buffers
README 文档
README
A simple manager for PHP output buffers. Can manage named or unnamed buffers.
Useage
The most common useage for this class is named output buffers, so that you can buffer multiple pieces of a page and then output them later in specific places.
<?php $bufferManager = new TJM\BufferManager(); $bufferManager->start('block1'); echo 'This is in block 1'; $bufferManager->end(); $bufferManager->start('block2'); echo 'This is in block 2'; $bufferManager->end(); ?> <div class="wrapper"> <h2>This is block 1's heading</h2> <div class="block1"><?php echo $bufferManager->get('block1'); ?></div> <h2>This is block 2's heading</h2> <div class="block2"><?php echo $bufferManager->get('block2'); ?></div> </div>
Here is an example for an HTML document, illustrating how it might be used to output the buffers in an HTML document, or in a JSON representation of that document if the request is via AJAX.
<?php $bufferManager->start('main'); include($mainContentFile); $bufferManager->end(); $bufferManager->start('aside'); include($asideContentFile); $bufferManager->end(); if($isAjaxRequest){ echo json_encode(Array( 'title'=> $pagetitle ,'main'=> $bufferManager->get('main') ,'aside'=> $bufferManager->get('aside') )); }else{ ?> <!DOCTYPE html> <html> <title><?=$pagetitle?></title> … <main><?=$bufferManager->get('main')?></main> <aside><?=$bufferManager->get('aside')?></aside> … </html>
统计信息
- 总下载量: 106
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-03-31