大神帮我看下,我的查询分页类哪里错了分页类
<br> 这是page.class.php<br> <?php <br /> class DividePage{//分页类<br> private $total;//要显示的总记录数<br> private $url;//请求的URL地址<br> private $displaypg;//每页显示的记录数,默认为每页显示10条记录<br> private $page;//当前页码<br> private $lastpg;//总页数,即最后一页的页码<br> private $prepg;//前一页<br> private $nextpg;//后一页<br> private $firstcount;//记录条数开始的序号从0开始<br> private $startd;//记录条数开始的记录号.<br> private $stopd;//记录条数结束的记录号.<br> <br> //构造函数<br> public function __construct($url, $total, $displaypg){<br> $this->url = $url;//请求的URL<br> $this->total = $total;//总记录数<br> //if($displaypg == '')<br> $this->displaypg = $displaypg;//每页显示的记录数<br> $this->initDividePage();//初始化分页类<br> //echo ','.$this->displaypg;<br> }<br> <br> //初始化分页类<br> private function initDividePage(){<br> //分析URL<br> $parse_url = parse_url($this->url);//将URL解释为有固定键值对的数组<br> $url_query = $parse_url['query'];//取出URL中的查询字符串<br> if($url_query){//如果有查询字符串,则删除查询字串中当前页的查询字段如:&page=$page或page=$page<br> ereg('(^|&)page=([0-9]*)', $url_query, $k);<br> $this->page = $k[2];//取得当前页的值<br> $url_query = ereg_replace("(^|&)page=$this->page", '', $url_query);//删除查询字串中当前页的查询字段如:&page=$page或page=$page<br> $this->url = str_replace($parse_url['query'], $url_query, $this->url);//保留其他的查询字串,<br> $this->page = $this->page ? $this->page : 1;//如果查询字符串中没有当前页的值就设当前页为1<br> if($url_query){//如果有其他查询字符串,则以&page=$page形式添加翻页查询字串<br> $this->url .= '&page';<br> }else{//如果没有其他查询字串,则以page=$page形式添加翻页查询字串<br> $this->url .= 'page';<br> }<br> }else{//如果没有查询字串,则在URL后添加?page=$page形式的翻页查询字串<br> $this->page = 1;<br> $this->url .= '?page';<br> }<br> $this->lastpg = ceil($this->total / $this->displaypg);//计算总页数,即最后一页的页码<br> $this->page = min($this->lastpg, $this->page);//如果当前页大于总页数,则当前页为最后一页的页码<br> $this->prepg = $this->page - 1;//上一页为当前页减一<br> $this->nextpg = $this->page + 1;//(($this->page == $this->lastpg) ? $this->lastpg : ($this->page + 1));//下一页为当前页加一,如果当前页为最后一页,则下一页为0<br> $this->firstcount = ($this->page - 1) * $this->displaypg;//计算当前页,记录条数开始的记录号,从0开始.<br> $this->startd = $this->total ? ($this->firstcount + 1) : 0;//记录开始号从1开始<br> $this->stopd = min($this->firstcount + $this->displaypg, $this->total);//记录结束号<br> //echo $this->displaypg;<br> //echo $this->nextpg.'+=+='.$this->lastpg;<br> }<br> <br> public function getPageInfo(){//取得当前页面的基本信息,如:显示第 1-10 条记录,共 23 条记录。<br> return '<span>显示第<span>'.$this->startd.'-'.$this->stopd.'</span>条记录,共<span>'.$this->total.'</span>条记录。</span>';<br> }<br> <br> public function getCommonPageNav(){//取得通常的分页导航,如:首页 上一页 下一页 尾页<br> $commonnav = '';<br> if($this->lastpg == 1){//如果只有一页,则返回翻页导航,退出,不显示下一页,上一页等。。。<br> return $commonnav;<br> break;<br> }<br> $commonnav = '<a>url.'=1" class="compagestyle">首页</a>';//设置首页导航,page=1<br> if($this->prepg){<br> $commonnav .= '<a>url.'='.$this->prepg.'" class="compagestyle">上一页</a>';<br> }else{ <div class="clear"> </div>

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools
