ThinkPHP学习札记(四)调试模式与日志记录

WBOY
Release: 2016-06-13 12:55:25
Original
783 people have browsed it

ThinkPHP学习笔记(四)调试模式与日志记录

在华丽的分割线之下是需要修改和可以进行配置的具体实现方法:

cong.php

'配置值'
//因为开启URL重新不论是被重写的还是没被重写的,都可以通过原有路径访问
//如果想开启rewrite模式,需要做如下操作
//1.query服务器已经开启了Apache的rewrite模块
//	LoadModule rewrite_module modules/mod_rewrite.so
//2.在与主入口文件,统计目录下,新建一个.htaccess(vi:save .htaccess;记事本:".htaccess")
//如果选用模式2(rewrite)会加大服务器的消耗
'URL_MODEL'=>1,

'URL_PATNINFO_MODEL'=>2,
//pathinfo包含两类
	//1普通模式:加上m和a:顺序关系可以发生变化
	//http://localhost/MyThinkPHP/admin.php/m/index/a/index
	//传值
	//http://localhost/MyThinkPHP/admin.php/m/index/a/index/username/zhangsan/password/password
	//2智能识别模块操作(默认模式就是智能识别)
	//http://localhost/MyThinkPHP/admin.php/index/index
	//传值
	//http://localhost/MyThinkPHP/admin.php/index/index/username/zhangsan/password/password
		

//修改URL分隔符
//'URL_PATHINFO_DEPR'=>'-',

//修改模板左右定界符
'TMPL_L_DELIM'=>'',


//********************************非常华丽的分割线**************************************

//开启调试模式
//1.模拟linux系统来识别大小写
//2.方法名的大小写与模板文件大小写有关
'APP_DEBUG'=>true,
//可以自定义页面的Trace信息
//配置文件路径的Trace信息配置在Thinkphp/Tpl下的pageTrace.tpl.php
//自定义方式:
//'TMPL_TRACE_FILE'=>APP_PATH.'/Public/trace.php',
//或者自定义个trace.php页面放入当前的Conf文件夹中

//默认调试文件的位置:
//ThinkPHP/Common/debug.php
//不缓存数据库字段;如果开启,再修改可以将Runtim/Data下面的文件进行删除
//'DB_FIELDS_CACHE'=> false,
//可以自定义的debug.php放入当前的Conf文件夹中

//先将APP_DEBUG设置为false然后在加入下面参数
//'APP_DEBUG'=>false,
//显示运行次此页面需要的时间
//'SHOW_RUN_TIME'=>true,
//显示详细的运行时间(基于SHOW_RUN_TIME)
//'SHOW_ADV_TIME'=>true,
//显示数据库的操作次数(基于SHOW_RUN_TIME)
//'SHOW_DB_TIMES'=>true,
//显示缓存的操作次数(基于SHOW_RUN_TIME)
//'SHOW_CACHE_TIMES'=>true,
//显示内存的开销(基于SHOW_RUN_TIME)
//'SHOW_USE_MEM'=>true,



//设置模板
//'DEFAULT_THEME'=>'default',



//日志处理log类:lib/Think/Core/log.class.php
//开启日志
'LOG_RECORD'=>true,
//日志处理log类:lib/Think/Core/log.class.php中有处理级别,可以选择性的加入
'LOG_RECORD_LEVEL'=>array('EMERG','ALERT'),

);
?>
Copy after login

在action中使用:

        
//模型调试(数据库中执行的操作语句)
$User=new Model('User');
$User->find(1);
//获取最后一次执行的sql
echo $User->getLastSql();

//使用:日志信息、日志级别、日志类型、具体信息
Log::write("aa",$level,$type,$file);
//record方法将信息写入到内存当中
        
        
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!