📄 clib.php
字号:
<?php
/*
//构造查询条件
class Make_condition
{
function Make_condition($name)
{
// 在全局数组 $globalref 中建立一个引用
global $globalref;
$globalref[] = &$this;
// 将名字设定为传递的值
$this->setName($name);
// 并输出之
$this->echoName();
}
function Make_like()
{
echo "<br>",$this->name;
}
function setName($name)
{
$this->name = $name;
}
} */
//翻页类
class Page{
var $totalpage;
var $stride;
var $currentpage;
//设置总页数
function setTotalpage($objpage=0){
$this->totalpage=$objpage;
}
//设置当前页
function setCurrentpage($objpage=1){
$this->currentpage=$objpage;
}
//设置跨度
function setStride($objStride=1){
$this->stride=$objStride;
}
//获得总页数
function getTotalpage(){
return $this->totalpage;
}
//获得跨读
function getStride($objStride=1){
return $this->stride;
}
//获取当前页
function getCurrentpage($objpage=1){
return $this->currentpage;
}
//打印分页
function Pageprint($q_url){
$willprint="";
for($Tmpa=0;$Tmpa<$this->totalpage;$Tmpa++){
if($Tmpa+$this->stride<$this->currentpage){//加了跨度还小于当前页的不显示
continue;
}
if($Tmpa+$this->stride==$this->currentpage){//刚好够跨度的页数
$p=$this->currentpage-$this->stride-1;
$willprint.="<a href=\"$_SERVER[PHP_SELF]?page=1&$q_url\"><strong><<</strong></a> <a href=\"$_SERVER[PHP_SELF]?page=$p&$q_url\"><strong><</strong></a> ";
}
if($Tmpa>$this->currentpage+$this->stride){//大于当前页+跨度的页面
break;
}
$willprint.="<a href=\"$_SERVER[PHP_SELF]?page=$Tmpa&$q_url\"><strong>第{$Tmpa}页</strong></a> ";
if($Tmpa==$this->currentpage+$this->stride){//刚好够跨度的页数
$p=$this->currentpage+$this->stride+1;
$willprint.="<a href=\"$_SERVER[PHP_SELF]?page=$p&$q_url\"><strong>></strong></a> <a href=\"$_SERVER[PHP_SELF]?page=$this->totalpage&$q_url\"><strong>>></strong></a>";
}
}
echo $willprint;
}//end of Pageprint
}//end of class of page
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -