解读_inc.php文件各函数的意义

2025-05-31 20:41:48

1、header("Content-type:text/html;charset=UTF-8");【header() 函数向东戳缨蜇客户端发送原始的 HTTP 报头。认识到一点很重要,即必须在任何实际的输出被发送之前调用 header() 函数(在 PHP 4 以及更高的版本中,您可以使用输出缓存来解决此问题):】@session_start();【@是为了抑制错误显示,让用户看不到,提升用户体验。注意:只是抑制错误,但是错误还是存在的。】require_once("./_config.php");require_once("./_cfg.php");require "inc/mysql.php";require "inc/func.php";require "inc/sql.php";【以上即请求导入这5个php文件,_config.php为配置文件,_cfg.php为网站设置参数文件,mysql.php为数据库处理函数类,sql.php为数据库处理函数文件,func.php为函数库】一般_inc.php指include即包含进网站运行需要的相关文件。

解读_inc.php文件各函数的意义

3、function classhtml($a,$b){if($GLOBALS['cfg_html']){return $a."-$b.html";}else{return $a.".php?classid=$b";}}【此函数传参两个,首先判断全局变量cfg_html是否为空,若非,则返回类似于aa-3.html的字符串,否则返回累死aa.php?classid=3这样的字符串。这个函数主要是为articles.php页面即列表页面服务的。】

解读_inc.php文件各函数的意义

6、function xia1($str){$data="";$classid=$GLOBALS['d芟鲠阻缒b']->v("my_cata|classid|classname='$str'");$result=$GLOBALS['db']->q("select classid,classname from my_cata where fid='$classid' order by ordernum desc,classid asc limit 0,3");while($rows=mysql_fetch_array($result)){if($GLOBALS['cfg_html']){$data.="<div class='lin'><a href=\"articles-".$rows['classid'].".html\">" . $rows['classname'] . "</a></div>";}else{$data.="<div class='lin'><a href=\"articles.php?classid=".$rows['classid']."\">" . $rows['classname'] . "</a></div>";}}$data.="";echo $data;}【这个函数与上面一个xia函数类似,不过取值只有3个。】

解读_inc.php文件各函数的意义

8、function acbyclassid($a,$b){$data="";$classid=$GLOBALS['db']->v("my_cata|classid|classid='$b'");if($GLOBALS['cfg_html']){$data="$a-$classid".".html";}else{$data="$a.php?classid=$classid";}$url=$GLOBALS['db']->v("my_cata|url|classid='$b'")."";if($url!=""){$data=$url;}echo $data;}【此函数的作用取值参数b到数据库中提取classid=b的一组数据,返回classid值,经过对全部变量cfg_html是否为空的判断,进行赋值操作。同理url也如此。】

解读_inc.php文件各函数的意义

10、function icbyclassid($a,$b){$data="";$classid=$GLOBALS['db']->v("my_cate|classid|classid='$b'");if($GLOBALS['cfg_html']){$data="$a-$classid.html";}else{$data="$a.php?classid=$classid";}$url=$GLOBALS['db']->v("my_cate|url|classid='$b'")."";if($url!=""){$data=$url;}echo $data;}【这个函数是对my_cate数据表的取值判断及赋值。这个与ic函数不同的是传值赋值给了classid而非classname。】

解读_inc.php文件各函数的意义

12、function aclassids($a){$data="";$result=$GLOBALS['稆糨孝汶;db']->q("select classid from my_cata where sorts like '%|" . $a . "|%'");echo $data;}【此函数按sorts字段取值。获取到classid值。】$mxdata=strtotime(date("Y-m-d H:i:s",time()));【将字符串转换为时间格式,依后面指定的格式。time() 函数返回当前时间的 Unix 时间戳。date()转换格式。strtotime("2012-11-02 08:36:51");这个是字符串转换成时间戳数据库读出来就这样写strtotime($rs['posttime']);time()这个是输出当前时间的时间戳strtotime还可以这样用,自己试试echo(strtotime("now"));echo(strtotime("3 October 2005"));echo(strtotime("+5 hours"));echo(strtotime("+1 week"));echo(strtotime("+1 week 3 days 7 hours 5 seconds"));echo(strtotime("next Monday"));echo(strtotime("last Sunday"));】

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢