努力思考 + 实践, 眼高手低是不行的. 注册 | 登陆
浏览模式: 标准 | 列表全部文章

php编写大型网站问题集

PHP以其易用性得到迅速的推广,但易用并不是说就能用好它,实际上许多程序员用它很容易的立一个个WEB应用系统,但又有多少人仔细的考虑过他们的代码,是否容易维护、是否足够健壮、否效率足够高、是否足够安全,当PHP用于建立大型网站时这些就成为很关键的因素。下面我们从较轻微的问题开始讨论,直至一些致命的错误。共分三部分。

【详见全文】

» 阅读全文

Tags: php经验, 项目, 问题

[2007.08.16]我的分页类, 附压缩包.

 打包(可直接运行查看效果):  pagebar.rar

PHP代码
  1. <?php   
  2.   
  3. /*  
  4.   Author: zwws  
  5.   Date: 2007.08.16  
  6. */  
  7.   
  8. class pagebar   
  9. {   
  10.     // 数据总数   
  11.     public $mRsCount;   
  12.     // 分页总数   
  13.     public $mPgCount;   
  14.     // 页码显示数   
  15.     public $mItemNum;   
  16.     // 当前页   
  17.     public $mCurrent;   
  18.   
  19.     // 构造函数(数据集, 每页显示记录数, 页码显示数, 当前页)   
  20.     function __construct($queryid$unitnum$itemnum$current) {   
  21.   
  22.         // 数据总数(实际使用)   
  23.         // $this->mRsCount = mysql_num_rows($queryid);   
  24.         // 数据总数(测试使用)   
  25.         $this->mRsCount = 500;   
  26.   
  27.         $this->mPgCount = ceil($this->mRsCount / $unitnum);   
  28.         $this->mItemNum = $itemnum;   
  29.         $this->mCurrent = $current;   
  30.   
  31.     }   
  32.   
  33.     // 分页页码   
  34.     function itemlist() {   
  35.   
  36.         // 此变量只为以下流程方便调用而设,并无实际含义   
  37.         $compare = floor($this->mItemNum / 2);   
  38.   
  39.         // 计算页码   
  40.         if ($this->mPgCount <= $this->mItemNum) {   
  41.             $start = 1;   
  42.             $end   = $this->mPgCount;   
  43.         } else {   
  44.             if ($this->mCurrent <= $compare) {   
  45.                 $start = 1;   
  46.                 $end   = $this->mItemNum;   
  47.             } elseif ($this->mCurrent + $compare > $this->mPgCount) {   
  48.                 $start = $this->mPgCount - $this->mItemNum + 1;   
  49.                 $end   = $this->mPgCount;   
  50.             } else {   
  51.                 $start = $this->mCurrent - ceil($this->mItemNum / 2) + 1;   
  52.                 $end   = $this->mCurrent + $compare;   
  53.             }   
  54.         }   
  55.   
  56.         // 生成页码   
  57.         return range($start$end);   
  58.   
  59.     }   
  60.   
  61.     // 分页信息   
  62.     function iteminfo() {   
  63.   
  64.         if ($this->mCurrent == 1) {   
  65.             $prev = null;   
  66.         } else {   
  67.             $prev = $this->mCurrent - 1;   
  68.         }   
  69.         if ($this->mCurrent == $this->mPgCount) {   
  70.             $next = null;   
  71.         } else {   
  72.             $next = $this->mCurrent + 1;   
  73.         }   
  74.   
  75.         if ($this->mCurrent > ceil($this->mItemNum / 2)) {   
  76.             $first = 1;   
  77.         } else {   
  78.             $first = null;   
  79.         }   
  80.         if ($this->mPgCount - $this->mCurrent > floor($this->mItemNum / 2)) {   
  81.             $last = $this->mPgCount;   
  82.         } else {   
  83.             $last = null;   
  84.         }   
  85.   
  86.         $iteminfo = array('first'   => $first,    
  87.                            'last'    => $last,   
  88.                            'prev'    => $prev,   
  89.                            'next'    => $next,   
  90.                            'current' => $this->mCurrent,   
  91.                            'rscount' => $this->mRsCount,   
  92.                            'pgcount' => $this->mPgCount);   
  93.   
  94.         return $iteminfo;   
  95.     }   
  96. }   
  97.   
  98. ?>  

 

Tags: php原创, 分页,

[公告] 关于博客变更的说明。

终于下决心换Blog了, 此次更换Blog有以下几个原因:

1. 不可否认PJblog是一个非常优秀的程序,但是可能是以为树大招风吧,被Spam盯上了,再加上PJblog更新又慢……偶都快被垃圾评论和留言折磨死了,实在是苦不堪言。
2.
SAblog简单实用, 安全性高是其一大特点(作者老A是安全界出生哒),太符合偶这个“极度缺乏安全感”的人的胃口了, 嘿嘿!
3.  现在自己专注于PHP + MySql的Web开发学习, 但原先使用的PJblog是ASP的,自己觉得有些不舒服。(不是理由的理由)
4. 被“逼”的。为啥?保密!

以前的Blog我会抽空陆续转过来的,毕竟是偶辛辛苦苦搜集的东东,血汗呐!

 

Tags: 公告

Records:115«6789101112131415