Home Backend Development PHP Tutorial ThinkPHP学习札记(四)调试模式与日志记录

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

Jun 13, 2016 pm 12:55 PM
gt index php rewrite

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

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

cong.php

<?php return array(

//更换模式最好删除一些~app.php和~runtime.php

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

'URL_PATNINFO_MODEL'=&gt;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'=&gt;'-',

//修改模板左右定界符
'TMPL_L_DELIM'=&gt;'<!--{',
'TMPL_R_DELIM'=>'}-->',


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

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

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

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



//设置模板
//'DEFAULT_THEME'=&gt;'default',



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

);
?&gt;
Copy after login

在action中使用:

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

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


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

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

See all articles