2020年5月12日
<?php
include './function.php';
$where='';//where条件
$search='';//搜索值
if(isset($_GET['search'])&& $_GET['search']){
$search = $_GET['search'];
$where ="WHERE content LIKE '%{$search}%'";
}
//分页功能
$count =query("SELECT count(*) as count FORM comment {$where}")['count'];
if($count=0){
exit('查询数据为空');
}
$pageNum=5;
$pagetotal=ceil($count / $pageNum);
$currentpage=isset($_GET['page'])? $_GET['page'] : 1;
$startOffset=($currentpage -1)* $pageNum;
$sy_y=($ceurrentpage -1)>0 ? $cerrentpage-1 :1;
$xy_y=($cerrentpage+1)>$pagetotal ? $pagetotal : $startOffset+1;
$limit="LIMIT{$startOffset},{$pageNum}";
$sql ="SELECT * FROM liuyan {$where} ORDER BY id DESC".$limit;
$data=caxum($sql);
<?php
include './function.php';
$where='';//where条件
$search='';//搜索值
if(isset($_GET['search'])&& $_GET['search']){
$search = $_GET['search'];
$where ="WHERE content LIKE '%{$search}%'";
}
//分页功能
$count =query("SELECT count(*) as count FORM comment {$where}")['count'];
if($count=0){
exit('查询数据为空');
}
$pageNum=5;
$pagetotal=ceil($count / $pageNum);
$currentpage=isset($_GET['page'])? $_GET['page'] : 1;
$startOffset=($currentpage -1)* $pageNum;
$sy_y=($ceurrentpage -1)>0 ? $cerrentpage-1 :1;
$xy_y=($cerrentpage+1)>$pagetotal ? $pagetotal : $startOffset+1;
$limit="LIMIT{$startOffset},{$pageNum}";
$sql ="SELECT * FROM liuyan {$where} ORDER BY id DESC".$limit;
$data=caxum($sql);
<?php
include './function.php';
$where='';//where条件
$search='';//搜索值
if(isset($_GET['search'])&& $_GET['search']){
$search = $_GET['search'];
$where ="WHERE content LIKE '%{$search}%'";
}
//分页功能
$count =query("SELECT count(*) as count FORM comment {$where}")['count'];
if($count=0){
exit('查询数据为空');
}
$pageNum=5;
$pagetotal=ceil($count / $pageNum);
$currentpage=isset($_GET['page'])? $_GET['page'] : 1;
$startOffset=($currentpage -1)* $pageNum;
$sy_y=($ceurrentpage -1)>0 ? $cerrentpage-1 :1;
$xy_y=($cerrentpage+1)>$pagetotal ? $pagetotal : $startOffset+1;
$limit="LIMIT{$startOffset},{$pageNum}";
$sql ="SELECT * FROM liuyan {$where} ORDER BY id DESC".$limit;
$data=caxum($sql);
笔记:
错误类型和错误级别:
错误类型:
语法错误:语法很常见,并且容易解决;一般写错;代码停止运行
运行时错误:运行代码是错误(变量不存在,参数传递错误),一般不影响代码执行,输出错误信息让后面继续运行
逻辑错误:最麻烦,代码不会停止,也不会输出错误信息;代码与你想得到的结果不一致;写错代码;造成代码逻辑与你所想的逻辑不一致
错误级别:
PHP手册>函数参数>影响php行为的扩展>错误处理>预定义常量
如何设置PHP的报错级别(配置文件)
修改了配置文件一定要记得重启
display_errors设置是否显示错误信息
当报错关闭提示时,发生了致命错误(代码停止运行的错误),网页显示500;
error_reporting 设置运行报告的错误级别
&并且
~排除
error_reporting()设置运行报告的错误级别;前提代码能够正常运行的情况下
临时改变允许报告的错误级别,当前文件有效
error_reporting(E_ALL &~E_NOTICE);
echo $b;
phpinfo();