目录
回复讨论(解决方案)
首页 后端开发 php教程 smarty分配的变量为什么在模板上输出不了?

smarty分配的变量为什么在模板上输出不了?

Jun 23, 2016 pm 02:20 PM

php smarty 分页

在网上找了一个分页类,加进自己需要的标签后,测试了一下,print_r可以打印输出,但是分配的到模板是空值,一时也没找到那出错了,请各位帮忙看看,急!
这个是修改的的分页类,pagediv.php
<?php /* //显示样式如下: //[1] 2 3 4 5 6 7 8 9 10 ...100 下页 尾页 //首页 上页 1..12 13 14 15 [16] 17 18 19 20 ...100 下页 尾页 //首页 上页 1..92 93 94 95 96 97 98 [99] 100 //使用方法: //$currentPage = $_GET['page']?$_GET['page']:1; //$pagediv = new pagediv(500, 10, 11, $currentPage, 'test.php?page='); //$pagediv->show(); */ class pagediv { public $part1; public $part2; public $part3; public $part4; public $part5; /* 对下面的分页显示进行分割: 首页 上页 1..12 13 14 15 [16] 17 18 19 20 ...100 下页 尾页 $part1 : 首页 上页 $part2 : 1.. $part3 : 12 13 14 15 [16] 17 18 19 20 $part4 : ...100 $part5 : 下页 尾页 */ public $allPage; //总页数 public $allRocords; //总记录数 public $perPage; //每页记录数 public $showPagesNo; //显示分页栏的总页码数 显示样式里共有11个 public $currentPage; //当前页 public $urlModel; //Url链接样式 public $startHidden; //出现 1... 时的页数 开始隐藏中间页 public $endHidden; //出现 ...100 时的页数 结束隐藏中间页 public function __construct($allRocords, $perPage, $showPagesNo, $currentPage, $urlModel){ $this->allRocords = $allRocords; $this->perPage = $perPage; $this->showPagesNo = $showPagesNo; $this->currentPage = $currentPage; $this->urlModel = $urlModel; $this->allPage = $this->getAllPage(); $this->startHidden = $this->getInt(($this->showPagesNo)/2); //6 $this->endHidden = $this->allPage - $this->startHidden; //94 } public function getUrl($_index = ''){ $_current = $_index; if($_index == 'pre') $_current = $this->currentPage -1; if($_index == 'next') $_current = $this->currentPage+1; if($_index == '') $_current = $this->allPage; return $this->urlModel.$_current; } public function getAllPage(){ return $this->getInt($this->allRocords/$this->perPage); } public function getInt($_float){ $_int = $_float; if( $_index = strpos($_float,'.') == true ){ $_int = substr($_float,0,$_index); $_int++; } //没有想起ceil时的候补方案 return $_int; } public function getPart1(){ $content = '<li class="icon-01"> <a href="'.$this->getUrl(1).'">首页</a></li> <li class="icon-02"><a href="'.$this->getUrl('pre').'">上页</a> </li>'; if($this->currentPage <= $this->startHidden){ $content = ''; } return $content; } public function getPart2(){ $content = '<li class="icon-03"> <a href="'.$this->getUrl(1).'">1</a> </li>'; $add = ''; if($this->currentPage > $this->startHidden){ $add = '...'; } if($this->currentPage == 1){ $content = '<li class="icon-03 icon-04">[1]</li>'; $add = ''; } $part2 = $content.$add; return $part2; } public function getPart3(){ $content = ''; if($this->currentPage <= $this->startHidden){ //[1] 2 3 4 5 6 7 8 9 10 ...100 下页 尾页 $long = $this->showPagesNo - 2; for($i=0;$i<$long;$i++){ $j = $i+2; if($j == $this->currentPage){ $content .= '<li class="icon-03 icon-04">['.$this->currentPage.']</li>'; }else{ $content .= '<li class="icon-03"> <a href="'.$this->getUrl($j).'">'.$j.'</a> </li>'; } } }elseif( $this->currentPage >= $this->endHidden ){ //首页 上页 1..92 93 94 95 96 97 98 [99] 100 $long = $this->showPagesNo - 2; $_start = $this->allPage - $long; for($i=0;$i<$long;$i++){ $j = $_start + $i; if($j == $this->currentPage){ $content .= '<li class="icon-03 icon-04">['.$this->currentPage.']</li> '; }else{ $content .= '<li class="icon-03"> <a href="'.$this->getUrl($j).'">'.$j.'</a> </li>'; } } }else{ //首页 上页 1..12 13 14 15 [16] 17 18 19 20 ...100 下页 尾页 $long = $this->showPagesNo - 2; $offset = $this->getInt($long/2) - 1; $_start = $this->currentPage - $offset; for($i=0;$i<$long;$i++){ $j = $_start + $i; if($j == $this->currentPage){ $content .= '<li class="icon-03 icon-04">['.$this->currentPage.']</li> '; }else{ $content .= '<li class="icon-03"> <a href="'.$this->getUrl($j).'">'.$j.'</a> </li>'; } } } $part3 = $content; return $part3; } public function getPart4(){ $content = '<li class="icon-03"> <a href="'.$this->getUrl().'">'.$this->allPage.'</a></li> '; $add = ''; if($this->currentPage < $this->endHidden){ $add = '...'; } if($this->currentPage == $this->allPage){ $content = '<li class="icon-03 icon-04">['.$this->allPage.']</li>'; $add = ''; } $part4 = $add.$content; return $part4; } public function getPart5(){ $content = '<li class="icon-02"> <a href="'.$this->getUrl('next').'">下页</a></li> <li class="icon-01"> <a href="'.$this->getUrl().'">尾页</a></li>'; if($this->currentPage >= $this->endHidden){ $content = ''; } return $content; } public function show(){ //判断非法 if(!is_numeric($this->currentPage) || $this->currentPage < 0 || $this->currentPage > $this->allPage){ print 'error:pageNo is flase'; return; } //总页数没有达到显示分页栏的总页码数,则全部显示 if($this->allPage < $this->showPagesNo){ $long = $this->allPage; for($i=0;$i<$long;$i++){ $j = $i+1; if($j == $this->currentPage){ $content .= '<li class="icon-03 icon-04">['.$this->currentPage.']</li> '; }else{ $content .= '<li class="icon-03"><a href="'.$this->getUrl($j).'">'.$j.'</a></li>'; } } print $content; return; } $this->part1 = $this->getPart1(); $this->part2 = $this->getPart2(); $this->part3 = $this->getPart3(); $this->part4 = $this->getPart4(); $this->part5 = $this->getPart5(); print $this->part1.$this->part2.$this->part3.$this->part4.$this->part5; } } ?> 
登录后复制


Video.php
$currentPage = $_GET['page']?$_GET['page']:1; $pagediv = new pagediv(500, 10, 5, $currentPage, 'Video.php?page='); $pages=$pagediv->show(); $smarty->assign('pages',$pages);$smarty->display('Video.html');
登录后复制


在模板上显示的时候不了。但是可以在模板打印。、

      <ul class="clk">		{$pages}            <div class="clear"></div>        </ul>
登录后复制


回复讨论(解决方案)

模板中是否有包含特殊的标记,smarty不识别。

分页类有问题。你可以用这个试试。

<?php/** *	作者:戚银 *	网名:诺天 *	QQ:804603662 *	邮箱:804603662@qq.com    noxiaotian@sina.com *	版权声明:完全开源 *	作者声明:我把这个分页类暂时命名为史上最强大的分页类,有点夸大,不喜勿喷。 *	作者期望:给分页类还存在一些不足之处,如果各位网友有好的意见或改进的方案,都可QQ联系作者予以讨论和交流 */class Page {	private $total;			//总数量	private $limit;			//返回mysql的limit语句	private $pageStart;		//开始的数值	private $pageStop;		//结束的数值	private $pageNumber;	//显示分页数字的数量	private $page;			//当前页	private $pageSize;		//每页显示的数量	private $pageToatl;		//分页的总数量	private $pageParam;		//分页变量	private $uri;			//URL参数	/**	 * 分页设置样式 不区分大小写	 * %pageToatl%  //总页数	 * %page%		//当前页	 * %pageSize% 	//当前页显示数据条数	 * %pageStart%	//本页起始条数	 * %pageStop%	//本页结束条数	 * %total%		//总数据条数	 * %first%		//首页	 * %ending%		//尾页	 * %up%			//上一页	 * %down%		//下一页	 * %F%			//起始页	 * %E%			//结束页	 * %omitFA%		//前省略加跳转	 * %omitEA%		//后省略加跳转	 * %omitF%		//前省略	 * %omitE%		//后省略	 * %numberF%	//固定数量的数字分页	 * %numberD%	//左右对等的数字分页	 * %input%		//跳转输入框	 * %GoTo%			//跳转按钮	 */	private $pageType = '<span class="pageher">第%page%页/共%pageToatl%页</span>%first%%up%%F%%omitFA%%numberF%%omitEA%%E%%down%%ending%';	//显示值设置	private $pageShow = array('first'=>'首页','ending'=>'尾页','up'=>'上一页','down'=>'下一页','GoTo'=>'GO');	/**	 * 初始化数据,构造方法	 * @access public	 * @param int $total 		数据总数量	 * @param int $pageSize 	每页显示条数	 * @param int $pageNumber 	分页数字显示数量(使用%numberF%和使用%numberD%会有不同的效果)	 * @param string $pageParam	分页变量	 * @return void	 */	public function __construct($total,$pageSize=10,$pageNumber=5,$pageParam='p'){		$this->total = $total<0?0:$total;		$this->pageSize = $pageSize<0?0:$pageSize;		$this->pageNumber = $pageNumber<0?0:$pageNumber;		$this->pageParam = $pageParam;		$this->calculate();	}	/**	 * 显示分页	 * @access public 	 * @return string HTML分页字符串	 */	public function pageShow(){		$this->uri();		if($this->pageToatl>1){			if($this->page == 1){				$first = '<span class="disabled">'.$this->pageShow['first'].'</span>';				$up = '<span class="disabled">'.$this->pageShow['up'].'</span>';			}else{				$first = '<a href="'.$this->uri.'&'.$this->pageParam.'=1">'.$this->pageShow['first'].'</a>';				$up = '<a href="'.$this->uri.'&'.$this->pageParam.'='.($this->page-1).'">'.$this->pageShow['up'].'</a>';			}			if($this->page >= $this->pageToatl){				$ending = '<span class="disabled">'.$this->pageShow['ending'].'</span>';				$down = '<span class="disabled">'.$this->pageShow['down'].'</span>';			}else{				$ending = '<a href="'.$this->uri.'&'.$this->pageParam.'='.$this->pageToatl.'">'.$this->pageShow['ending'].'</a>';				$down = '<a href="'.$this->uri.'&'.$this->pageParam.'='.($this->page+1).'">'.$this->pageShow['down'].'</a>';			}			$input  = '<input type="text" value="'.$this->page.'" onkeydown="javascript: if(event.keyCode==13){var value = parseInt(this.value); var page=(value>'.$this->pageToatl.') ? '.$this->pageToatl.' : value;  location=\''.$this->uri.'&'.$this->pageParam.'=\'+page+\'\'; return false;}">';			$GoTo = '<button onclick="javascript:var value=parseInt(this.previousSibling.value); var page=(value>'.$this->pageToatl.') ? '.$this->pageToatl.' : value;  location=\''.$this->uri.'&'.$this->pageParam.'=\'+page+\'\'; return false;">'.$this->pageShow['GoTo'].'</button>';		}else{			$first = '';$up ='';$ending = '';$down = '';$input = '';$GoTo = '';		}		$this->numberF();		return str_ireplace(array('%pageToatl%','%page%','%pageSize%','%pageStart%','%pageStop%','%total%','%first%','%ending%','%up%','%down%','%input%','%GoTo%'),array($this->pageToatl,$this->page,$this->pageStop-$this->pageStart,$this->pageStart,$this->pageStop,$this->total,$first,$ending,$up,$down,$input,$GoTo),$this->pageType);	}		/**	 *	数字分页	 */	private function numberF(){		$pageF = stripos($this->pageType,'%numberF%');		$pageD = stripos($this->pageType,'%numberD%');		$numberF = '';$numberD = '';$F = '';$E ='';$omitF = '';$omitFA = '';$omitE = '';$omitEA = '';		if($pageF!==false || $pageD!==false){			if($pageF!==false){				$number = $this->pageNumber%2==0?$this->pageNumber/2:($this->pageNumber+1)/2;				$DStart = $this->page - $number<0?$this->page - $number-1:0;				if($this->page+$number-$DStart > $this->pageToatl){					$DStop = ($this->page+$number-$DStart) - $this->pageToatl;					$forStop = $this->pageToatl+1;				}else{					$DStop = 0;					$forStop = $this->page+$number-$DStart+1;				}				$forStart = $this->page-$number-$DStop<1?1:$this->page-$number-$DStop;				for($i=$forStart;$i<$forStop;++$i){					if($i==$this->page){						$numberF .= '<span class="current">'.$i.'</span>';					}else{						$numberF .= '<a href="'.$this->uri.'&'.$this->pageParam.'='.$i.'">'.$i.'</a>';					}				}			}			if($pageD!==false){				$number = $this->pageNumber;				$forStart = $this->page-$number>0?$this->page-$number:1;				$forStop = $this->page+$number>$this->pageToatl?$this->pageToatl+1:$this->page+$number+1;				for($i=$forStart;$i<$this->page;++$i){					$numberD .= '<a href="'.$this->uri.'&'.$this->pageParam.'='.$i.'">'.$i.'</a>';				}				$numberD .= '<span class="current">'.$this->page.'</span>';				$start = $this->page+1;				for($i=$start;$i<$forStop;++$i){					$numberD .= '<a href="'.$this->uri.'&'.$this->pageParam.'='.$i.'">'.$i.'</a>';				}			}			$F = $forStart>1?'<a href="'.$this->uri.'&'.$this->pageParam.'=1">1</a>':'';			$E = $forStop<$this->pageToatl+1?'<a href="'.$this->uri.'&'.$this->pageParam.'='.$this->pageToatl.'">'.$this->pageToatl.'</a>':'';			if($forStart>2){				$omitF = '<span  class="omit">…</span>';				$startA = $this->page-$number<1?1:$this->page-$number;				$omitFA = '<a  class="omit" href="'.$this->uri.'&'.$this->pageParam.'='.$startA.'">…</a>';			}			if($forStop<$this->pageToatl){				$omitE = '<span class="omit">…</span>';				$stopA = $this->page+$number>$this->pageToatl?$this->pageToatl:$this->page+$number;				$omitEA = '<a  class="omit" href="'.$this->uri.'&'.$this->pageParam.'='.$stopA.'">…</a>';			}		}		$this->pageType = str_ireplace(array('%F%','%E%','%omitFA%','%omitEA%','%omitF%','%omitE%','%numberF%','%numberD%'),array($F,$E,$omitFA,$omitEA,$omitF,$omitE,$numberF,$numberD),$this->pageType);	}	/**	 *	处理url的方法	 * @access public	 * @param array   $url 	保持URL直对关系数组	 * @return string 		过滤后的url尾参数	 */	private function uri(){		$url = $_SERVER["REQUEST_URI"];		$par = parse_url($url);		if (isset($par['query'])) {			parse_str($par['query'],$query);			if(!is_array($this->uri)){				$this->uri = array();			}			array_merge($query,$this->uri);			unset($query[$this->pageParam]);			while($key = array_search('',$query)){				unset($query[$key]);			}			$this->uri = $par['path'].'?'.http_build_query($query);		}else{			$this->uri = $par['path'].'?';		}	}	/**	 * 设置limit方法及计算起始条数和结束条数	 */	private function calculate(){		$this->pageToatl = ceil($this->total/$this->pageSize);		$this->page = intval($_GET[$this->pageParam]);		$this->page = $this->page>=1?$this->page>$this->pageToatl?$this->pageToatl:$this->page:1;		$this->pageStart = ($this->page-1)*$this->pageSize;		$this->pageStop = $this->pageStart+$this->pageSize;		$this->pageStop = $this->pageStop>$this->total?$this->total:$this->pageStop;		$this->limit = $this->pageStart.','.$this->pageStop;	}	/**	 * 设置过滤器	 */	public function __set($name,$value){		switch($name){			case 'pageType':			case 'uri':				$this->$name = $value;				return;			case 'pageShow':				if(is_array($value)){					$this->pageShow = array_merge($this->pageShow,$value);				}				return;		}	}	/**	 * 取值过滤器	 */	public function __get($name){		switch($name){			case 'limit':			case 'pageStart':			case 'pageStop':				return $this->$name;			default:				return;		}	}}
登录后复制
登录后复制

分页类有问题。你可以用这个试试。

<?php/** *	作者:戚银 *	网名:诺天 *	QQ:804603662 *	邮箱:804603662@qq.com    noxiaotian@sina.com *	版权声明:完全开源 *	作者声明:我把这个分页类暂时命名为史上最强大的分页类,有点夸大,不喜勿喷。 *	作者期望:给分页类还存在一些不足之处,如果各位网友有好的意见或改进的方案,都可QQ联系作者予以讨论和交流 */class Page {	private $total;			//总数量	private $limit;			//返回mysql的limit语句	private $pageStart;		//开始的数值	private $pageStop;		//结束的数值	private $pageNumber;	//显示分页数字的数量	private $page;			//当前页	private $pageSize;		//每页显示的数量	private $pageToatl;		//分页的总数量	private $pageParam;		//分页变量	private $uri;			//URL参数	/**	 * 分页设置样式 不区分大小写	 * %pageToatl%  //总页数	 * %page%		//当前页	 * %pageSize% 	//当前页显示数据条数	 * %pageStart%	//本页起始条数	 * %pageStop%	//本页结束条数	 * %total%		//总数据条数	 * %first%		//首页	 * %ending%		//尾页	 * %up%			//上一页	 * %down%		//下一页	 * %F%			//起始页	 * %E%			//结束页	 * %omitFA%		//前省略加跳转	 * %omitEA%		//后省略加跳转	 * %omitF%		//前省略	 * %omitE%		//后省略	 * %numberF%	//固定数量的数字分页	 * %numberD%	//左右对等的数字分页	 * %input%		//跳转输入框	 * %GoTo%			//跳转按钮	 */	private $pageType = '<span class="pageher">第%page%页/共%pageToatl%页</span>%first%%up%%F%%omitFA%%numberF%%omitEA%%E%%down%%ending%';	//显示值设置	private $pageShow = array('first'=>'首页','ending'=>'尾页','up'=>'上一页','down'=>'下一页','GoTo'=>'GO');	/**	 * 初始化数据,构造方法	 * @access public	 * @param int $total 		数据总数量	 * @param int $pageSize 	每页显示条数	 * @param int $pageNumber 	分页数字显示数量(使用%numberF%和使用%numberD%会有不同的效果)	 * @param string $pageParam	分页变量	 * @return void	 */	public function __construct($total,$pageSize=10,$pageNumber=5,$pageParam='p'){		$this->total = $total<0?0:$total;		$this->pageSize = $pageSize<0?0:$pageSize;		$this->pageNumber = $pageNumber<0?0:$pageNumber;		$this->pageParam = $pageParam;		$this->calculate();	}	/**	 * 显示分页	 * @access public 	 * @return string HTML分页字符串	 */	public function pageShow(){		$this->uri();		if($this->pageToatl>1){			if($this->page == 1){				$first = '<span class="disabled">'.$this->pageShow['first'].'</span>';				$up = '<span class="disabled">'.$this->pageShow['up'].'</span>';			}else{				$first = '<a href="'.$this->uri.'&'.$this->pageParam.'=1">'.$this->pageShow['first'].'</a>';				$up = '<a href="'.$this->uri.'&'.$this->pageParam.'='.($this->page-1).'">'.$this->pageShow['up'].'</a>';			}			if($this->page >= $this->pageToatl){				$ending = '<span class="disabled">'.$this->pageShow['ending'].'</span>';				$down = '<span class="disabled">'.$this->pageShow['down'].'</span>';			}else{				$ending = '<a href="'.$this->uri.'&'.$this->pageParam.'='.$this->pageToatl.'">'.$this->pageShow['ending'].'</a>';				$down = '<a href="'.$this->uri.'&'.$this->pageParam.'='.($this->page+1).'">'.$this->pageShow['down'].'</a>';			}			$input  = '<input type="text" value="'.$this->page.'" onkeydown="javascript: if(event.keyCode==13){var value = parseInt(this.value); var page=(value>'.$this->pageToatl.') ? '.$this->pageToatl.' : value;  location=\''.$this->uri.'&'.$this->pageParam.'=\'+page+\'\'; return false;}">';			$GoTo = '<button onclick="javascript:var value=parseInt(this.previousSibling.value); var page=(value>'.$this->pageToatl.') ? '.$this->pageToatl.' : value;  location=\''.$this->uri.'&'.$this->pageParam.'=\'+page+\'\'; return false;">'.$this->pageShow['GoTo'].'</button>';		}else{			$first = '';$up ='';$ending = '';$down = '';$input = '';$GoTo = '';		}		$this->numberF();		return str_ireplace(array('%pageToatl%','%page%','%pageSize%','%pageStart%','%pageStop%','%total%','%first%','%ending%','%up%','%down%','%input%','%GoTo%'),array($this->pageToatl,$this->page,$this->pageStop-$this->pageStart,$this->pageStart,$this->pageStop,$this->total,$first,$ending,$up,$down,$input,$GoTo),$this->pageType);	}		/**	 *	数字分页	 */	private function numberF(){		$pageF = stripos($this->pageType,'%numberF%');		$pageD = stripos($this->pageType,'%numberD%');		$numberF = '';$numberD = '';$F = '';$E ='';$omitF = '';$omitFA = '';$omitE = '';$omitEA = '';		if($pageF!==false || $pageD!==false){			if($pageF!==false){				$number = $this->pageNumber%2==0?$this->pageNumber/2:($this->pageNumber+1)/2;				$DStart = $this->page - $number<0?$this->page - $number-1:0;				if($this->page+$number-$DStart > $this->pageToatl){					$DStop = ($this->page+$number-$DStart) - $this->pageToatl;					$forStop = $this->pageToatl+1;				}else{					$DStop = 0;					$forStop = $this->page+$number-$DStart+1;				}				$forStart = $this->page-$number-$DStop<1?1:$this->page-$number-$DStop;				for($i=$forStart;$i<$forStop;++$i){					if($i==$this->page){						$numberF .= '<span class="current">'.$i.'</span>';					}else{						$numberF .= '<a href="'.$this->uri.'&'.$this->pageParam.'='.$i.'">'.$i.'</a>';					}				}			}			if($pageD!==false){				$number = $this->pageNumber;				$forStart = $this->page-$number>0?$this->page-$number:1;				$forStop = $this->page+$number>$this->pageToatl?$this->pageToatl+1:$this->page+$number+1;				for($i=$forStart;$i<$this->page;++$i){					$numberD .= '<a href="'.$this->uri.'&'.$this->pageParam.'='.$i.'">'.$i.'</a>';				}				$numberD .= '<span class="current">'.$this->page.'</span>';				$start = $this->page+1;				for($i=$start;$i<$forStop;++$i){					$numberD .= '<a href="'.$this->uri.'&'.$this->pageParam.'='.$i.'">'.$i.'</a>';				}			}			$F = $forStart>1?'<a href="'.$this->uri.'&'.$this->pageParam.'=1">1</a>':'';			$E = $forStop<$this->pageToatl+1?'<a href="'.$this->uri.'&'.$this->pageParam.'='.$this->pageToatl.'">'.$this->pageToatl.'</a>':'';			if($forStart>2){				$omitF = '<span  class="omit">…</span>';				$startA = $this->page-$number<1?1:$this->page-$number;				$omitFA = '<a  class="omit" href="'.$this->uri.'&'.$this->pageParam.'='.$startA.'">…</a>';			}			if($forStop<$this->pageToatl){				$omitE = '<span class="omit">…</span>';				$stopA = $this->page+$number>$this->pageToatl?$this->pageToatl:$this->page+$number;				$omitEA = '<a  class="omit" href="'.$this->uri.'&'.$this->pageParam.'='.$stopA.'">…</a>';			}		}		$this->pageType = str_ireplace(array('%F%','%E%','%omitFA%','%omitEA%','%omitF%','%omitE%','%numberF%','%numberD%'),array($F,$E,$omitFA,$omitEA,$omitF,$omitE,$numberF,$numberD),$this->pageType);	}	/**	 *	处理url的方法	 * @access public	 * @param array   $url 	保持URL直对关系数组	 * @return string 		过滤后的url尾参数	 */	private function uri(){		$url = $_SERVER["REQUEST_URI"];		$par = parse_url($url);		if (isset($par['query'])) {			parse_str($par['query'],$query);			if(!is_array($this->uri)){				$this->uri = array();			}			array_merge($query,$this->uri);			unset($query[$this->pageParam]);			while($key = array_search('',$query)){				unset($query[$key]);			}			$this->uri = $par['path'].'?'.http_build_query($query);		}else{			$this->uri = $par['path'].'?';		}	}	/**	 * 设置limit方法及计算起始条数和结束条数	 */	private function calculate(){		$this->pageToatl = ceil($this->total/$this->pageSize);		$this->page = intval($_GET[$this->pageParam]);		$this->page = $this->page>=1?$this->page>$this->pageToatl?$this->pageToatl:$this->page:1;		$this->pageStart = ($this->page-1)*$this->pageSize;		$this->pageStop = $this->pageStart+$this->pageSize;		$this->pageStop = $this->pageStop>$this->total?$this->total:$this->pageStop;		$this->limit = $this->pageStart.','.$this->pageStop;	}	/**	 * 设置过滤器	 */	public function __set($name,$value){		switch($name){			case 'pageType':			case 'uri':				$this->$name = $value;				return;			case 'pageShow':				if(is_array($value)){					$this->pageShow = array_merge($this->pageShow,$value);				}				return;		}	}	/**	 * 取值过滤器	 */	public function __get($name){		switch($name){			case 'limit':			case 'pageStart':			case 'pageStop':				return $this->$name;			default:				return;		}	}}
登录后复制
登录后复制


这个不错,谢谢!
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

<🎜>:泡泡胶模拟器无穷大 - 如何获取和使用皇家钥匙
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系统,解释
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆树的耳语 - 如何解锁抓钩
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

热门话题

Java教程
1676
14
CakePHP 教程
1429
52
Laravel 教程
1333
25
PHP教程
1278
29
C# 教程
1257
24
说明PHP中的安全密码散列(例如,password_hash,password_verify)。为什么不使用MD5或SHA1? 说明PHP中的安全密码散列(例如,password_hash,password_verify)。为什么不使用MD5或SHA1? Apr 17, 2025 am 12:06 AM

在PHP中,应使用password_hash和password_verify函数实现安全的密码哈希处理,不应使用MD5或SHA1。1)password_hash生成包含盐值的哈希,增强安全性。2)password_verify验证密码,通过比较哈希值确保安全。3)MD5和SHA1易受攻击且缺乏盐值,不适合现代密码安全。

PHP类型提示如何起作用,包括标量类型,返回类型,联合类型和无效类型? PHP类型提示如何起作用,包括标量类型,返回类型,联合类型和无效类型? Apr 17, 2025 am 12:25 AM

PHP类型提示提升代码质量和可读性。1)标量类型提示:自PHP7.0起,允许在函数参数中指定基本数据类型,如int、float等。2)返回类型提示:确保函数返回值类型的一致性。3)联合类型提示:自PHP8.0起,允许在函数参数或返回值中指定多个类型。4)可空类型提示:允许包含null值,处理可能返回空值的函数。

PHP和Python:解释了不同的范例 PHP和Python:解释了不同的范例 Apr 18, 2025 am 12:26 AM

PHP主要是过程式编程,但也支持面向对象编程(OOP);Python支持多种范式,包括OOP、函数式和过程式编程。PHP适合web开发,Python适用于多种应用,如数据分析和机器学习。

您如何防止PHP中的SQL注入? (准备的陈述,PDO) 您如何防止PHP中的SQL注入? (准备的陈述,PDO) Apr 15, 2025 am 12:15 AM

在PHP中使用预处理语句和PDO可以有效防范SQL注入攻击。1)使用PDO连接数据库并设置错误模式。2)通过prepare方法创建预处理语句,使用占位符和execute方法传递数据。3)处理查询结果并确保代码的安全性和性能。

PHP和Python:代码示例和比较 PHP和Python:代码示例和比较 Apr 15, 2025 am 12:07 AM

PHP和Python各有优劣,选择取决于项目需求和个人偏好。1.PHP适合快速开发和维护大型Web应用。2.Python在数据科学和机器学习领域占据主导地位。

PHP:处理数据库和服务器端逻辑 PHP:处理数据库和服务器端逻辑 Apr 15, 2025 am 12:15 AM

PHP在数据库操作和服务器端逻辑处理中使用MySQLi和PDO扩展进行数据库交互,并通过会话管理等功能处理服务器端逻辑。1)使用MySQLi或PDO连接数据库,执行SQL查询。2)通过会话管理等功能处理HTTP请求和用户状态。3)使用事务确保数据库操作的原子性。4)防止SQL注入,使用异常处理和关闭连接来调试。5)通过索引和缓存优化性能,编写可读性高的代码并进行错误处理。

PHP的目的:构建动态网站 PHP的目的:构建动态网站 Apr 15, 2025 am 12:18 AM

PHP用于构建动态网站,其核心功能包括:1.生成动态内容,通过与数据库对接实时生成网页;2.处理用户交互和表单提交,验证输入并响应操作;3.管理会话和用户认证,提供个性化体验;4.优化性能和遵循最佳实践,提升网站效率和安全性。

在PHP和Python之间进行选择:指南 在PHP和Python之间进行选择:指南 Apr 18, 2025 am 12:24 AM

PHP适合网页开发和快速原型开发,Python适用于数据科学和机器学习。1.PHP用于动态网页开发,语法简单,适合快速开发。2.Python语法简洁,适用于多领域,库生态系统强大。

See all articles