tjm/buffermanager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-03-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固