PHP以其易用性得到迅速的推广,但易用并不是说就能用好它,实际上许多程序员用它很容易的立一个个WEB应用系统,但又有多少人仔细的考虑过他们的代码,是否容易维护、是否足够健壮、否效率足够高、是否足够安全,当PHP用于建立大型网站时这些就成为很关键的因素。下面我们从较轻微的问题开始讨论,直至一些致命的错误。共分三部分。
【详见全文】
» 阅读全文
打包(可直接运行查看效果): pagebar.rar
PHP代码
- <?php
-
-
-
-
-
-
- class pagebar
- {
-
- public $mRsCount;
-
- public $mPgCount;
-
- public $mItemNum;
-
- public $mCurrent;
-
-
- function __construct($queryid, $unitnum, $itemnum, $current) {
-
-
-
-
- $this->mRsCount = 500;
-
- $this->mPgCount = ceil($this->mRsCount / $unitnum);
- $this->mItemNum = $itemnum;
- $this->mCurrent = $current;
-
- }
-
-
- function itemlist() {
-
-
- $compare = floor($this->mItemNum / 2);
-
-
- if ($this->mPgCount <= $this->mItemNum) {
- $start = 1;
- $end = $this->mPgCount;
- } else {
- if ($this->mCurrent <= $compare) {
- $start = 1;
- $end = $this->mItemNum;
- } elseif ($this->mCurrent + $compare > $this->mPgCount) {
- $start = $this->mPgCount - $this->mItemNum + 1;
- $end = $this->mPgCount;
- } else {
- $start = $this->mCurrent - ceil($this->mItemNum / 2) + 1;
- $end = $this->mCurrent + $compare;
- }
- }
-
-
- return range($start, $end);
-
- }
-
-
- function iteminfo() {
-
- if ($this->mCurrent == 1) {
- $prev = null;
- } else {
- $prev = $this->mCurrent - 1;
- }
- if ($this->mCurrent == $this->mPgCount) {
- $next = null;
- } else {
- $next = $this->mCurrent + 1;
- }
-
- if ($this->mCurrent > ceil($this->mItemNum / 2)) {
- $first = 1;
- } else {
- $first = null;
- }
- if ($this->mPgCount - $this->mCurrent > floor($this->mItemNum / 2)) {
- $last = $this->mPgCount;
- } else {
- $last = null;
- }
-
- $iteminfo = array('first' => $first,
- 'last' => $last,
- 'prev' => $prev,
- 'next' => $next,
- 'current' => $this->mCurrent,
- 'rscount' => $this->mRsCount,
- 'pgcount' => $this->mPgCount);
-
- return $iteminfo;
- }
- }
-
- ?>
终于下决心换Blog了, 此次更换Blog有以下几个原因:
1. 不可否认PJblog是一个非常优秀的程序,但是可能是以为树大招风吧,被Spam盯上了,再加上PJblog更新又慢……偶都快被垃圾评论和留言折磨死了,实在是苦不堪言。
2. SAblog简单实用, 安全性高是其一大特点(作者老A是安全界出生哒),太符合偶这个“极度缺乏安全感”的人的胃口了, 嘿嘿!
3. 现在自己专注于PHP + MySql的Web开发学习, 但原先使用的PJblog是ASP的,自己觉得有些不舒服。(不是理由的理由)
4. 被“逼”的。为啥?保密!
以前的Blog我会抽空陆续转过来的,毕竟是偶辛辛苦苦搜集的东东,血汗呐!