Exemplo n.º 1
0
这是个简单的例子,所以并不代表最正确优化的方案

作了个简单测试:
访问index.html apache每秒响应290次
访问index.php apache每秒响应19次
可以发现静态页是动态页的15倍
*/
session_start();
require 'common.php';
require 'lib/BluePage/BluePage.class.php';
// 包含分页类
$count = $query->result($query->query("SELECT count(*) as count FROM gb_content"), 'count');
//总行数
$lines = 10;
// 每页行数
$pBP = new BluePage($count, $lines);
// 实例化分页类
$aPDatas = $pBP->get();
//分页返回结果
$limit = $aPDatas['offset'];
//起始行
$result = $query->query('SELECT * FROM gb_content order by id desc limit ' . $limit . ',' . $lines);
//查询数据
$gblist = array();
while ($row = $query->fetch_array($result)) {
    // 取一条数据
    $row['username'] = htmlentities($row['username'], ENT_COMPAT, 'utf-8');
    $row['content'] = preg_replace('/(http[s]?:\\/\\/[A-Za-z0-9]+\\.[A-Za-z0-9]+[\\/=\\?%\\-&_~`@[\\]\':+!]*([^<>\\"\\"\\s])*)/i', '<a target="_blank" href="$1">$1</a>', htmlentities($row['content'], ENT_COMPAT, 'utf-8'));
    $gblist[] = $row;
}
$query->free_result($result);
Exemplo n.º 2
0
<?php

include "BluePage.class.php";
$intCount = 1000;
$intShowNum = 10;
header("Content-Type:text/html;charset=gb2312");
$pBP = new BluePage($intCount, $intShowNum);
$aPDatas = $pBP->get();
$intOffset = $aPDatas[offset];
$strHtml = $pBP->getHTML($aPDatas);
echo $strHtml;