写项目中整理的一些小笔记
- 合并input框最好用浮动
- $_SESSION 是全局变量(前台调用) $data只是页面内虚拟的数据
- Empty标签用于判断某个变量是否为空
<empty name="name">
name为空
<else />
name不为空
</empty>
4. 标签内字符串的截取: |mb_substr = 0,num,’utf-8’
5.前台页面获取后台定义的html : |htmlspecialchars_decode
6.页面内获取时间 : {$time|date=”Y-m-d H:i:s”,###}
7.php中输出时间: var_dump(date(‘Y-m-d H:i:s’,time()))
8.$this->assign()=>赋值 $this->display()=>输出模板
9.Field(true)的用法会显示获取数据表的所有字段列表
10.分页
$app = M(‘’);=>获取数据库
$count=$app->count();
$page=new\Think|Page($count,num);
$show=$page->show();
$apps=$app->order(‘id desc’)->limit($page->firstRow.’,’.$page->listRows->select())
$num=($page->nowpage-1)*($page->listRows)+1;
11.调取数据库内单个字段信息
$tui = M('ershou')->where('posid=1')->order("id desc")->select();
//$tui['pic']=M('ershou')->where('id='.$tui['id'])->find()[thumb];
foreach ($tui as $k=>$v){
$tui[$k]['pic']=M('ershou')->where('id='.$v['id'])->find()['thumb'];
$tui[$k]['tit']=M('ershou')->where('id='.$v['id'])->find()['title'];
$tui[$k]['shi']=M('ershou')->where('id='.$v['id'])->find()['shi'];
$tui[$k]['ting']=M('ershou')->where('id='.$v['id'])->find()['ting'];
$tui[$k]['mianji']=M('ershou')->where('id='.$v['id'])->find()['jianzhumianji'];
$tui[$k]['dizhi']=M('ershou')->where('id='.$v['id'])->find()['zuobiaodizhi'];
}
$this -> assign('tui',$tui);
12.处理跨域请求
public function _initialize(){
//处理跨域问题
header('Content-Type:application/json; charset=utf-8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Max-Age:86400'); // 允许访问的有效期
header('Access-Control-Allow-Headers:*');
header('Access-Control-Allow-Methods:OPTIONS, GET, POST, DELETE');
}
13.Ajax返回数据赋值给前台变量