Table of Contents
1.说明:" >1.说明:
2.核心内容:" >2.核心内容:
一.ThinkPHP框架对应MVC目录" >一.ThinkPHP框架对应MVC目录
二.URL访问方式(4种)" >二.URL访问方式(4种)
三.应用配置" >三.应用配置
3.工程实例:  " >3.工程实例:  
4.文件路径:" >4.文件路径:
5.遇到的问题: " >5.遇到的问题: 
6.文档:" >6.文档:

第二课 

Jun 13, 2016 pm 12:01 PM
false gt nbsp quot

ThinkPHP第二课 框架MVC目录和URL访问方式

第二课 框架MVC目录和URL访问方式

1.说明:

ThinkPHP是基于MVC的框架,认识框架目录将更好的实现分层,掌握ThinkPHPURL访问就是访问框架的控制器(MVC中的C),共有四种方式,框架中的C起到分模块的作用

url4种访问方式:

1.PATHINFO 模式 -- 重点!!!!!!

http://域名/项目名/入口文件/模块名/方法名/1/1/2/2

2.普通模式

http://域名/项目名/入口文件?m=模块名&a=方法名&1=1&2=2

3.REWRITE模式

http://域名/项目名/模块名/方法名/1/1/2/2

4.兼容模式

http://域名/项目名/入口文件?s=模块名/方法名/1/1/2/2

2.核心内容:

一.ThinkPHP框架对应MVC目录

V(视图层):thinkphp\Home\Tpl

M(模型层):thinkphp\Home\Lib\Model

C(控制器):thinkphp\Home\Lib\Action

二.URL访问方式(4种)

(1)入口文件全名+控制器类前缀名+控制器核心方法名

thinkphp/index.php/Index/indexPATHINFO方式)



(2)普通模式

  

3REWRITE模式

4)兼容模式

三.应用配置


3.工程实例:  

传参访问控制器实例(键值对)


4.文件路径:

5.遇到的问题: 

6.文档:

ThinkPHPconfig.php详细配置文件介绍 

return array(

//模版配置
//------------------------------------------------------------------------------
"TMPL_DETECT_THEME"   =>  false ,   //自动侦测模板主题 
"TMPL_TEMPLATE_SUFFIX"=>'.html',    //默认模板文件后缀
"TMPL_CACHFILE_SUFFIX"=>'.php',     //默认模板缓存后缀
"TMPL_PARSE_STRING"   => '',        //模板引擎要自动替换的字符串,必须是数组形式。例如 array('__MYPATH__'=>Lib_PATH,...) 
"TMPL_ACTION_ERROR"   =>'Public:error',    //错误跳转模板文件 
"TMPL_ACTION_SUCCESS" =>'Public:success', //成功跳转模板文件 
"TMPL_TRACE_FILE"     =>THINK_PATH.'/Tpl/PageTrace.tpl.php',   //页面Trace的模板文件 
"TMPL_EXCEPTION_FILE" =>THINK_PATH.'/Tpl/ThinkException.tpl.php',  //异常页面的模板文件 
"TMPL_ENGINE_TYPE"    => 'Think',    //默认模板引擎 
//以下设置仅对使用Think模板引擎有效 
"TMPL_DENY_FUNC_LIST" =>'echo,exit',  //模板引擎禁用函数 
"TMPL_L_DELIM"        =>'{',    //模板引擎普通标签开始标记 
"TMPL_R_DELIM"        =>'}',    //模板引擎普通标签结束标记 
"TMPL_VAR_IDENTIFY"   =>'array',    //模板变量识别 留空自懂判断 array 数组 obj 对象 
"TMPL_FILE_DEPR"      =>'/',     //模板文件MODULE_NAMEACTION_NAME之间的分割符,只对项目分组部署有效 
"TMPL_STRIP_SPACE"    =>false,    //是否去除模板文件里面癿html空格不换行 
"TMPL_CACHE_ON"       =>true,    //默认开启模板编译缓存 false 的话每次都重新编译模板 
"TMPL_CACHE_TIME"     => -1,     //模板缓存有效期 -1 永久 单位为秒 
"TAGLIB_BEGIN"        =>'标签库标签开始标记 

"TAGLIB_END"          =>'>',     //标签库标签结束标记 
"TAGLIB_BUILD_IN"     =>'cx',    //内置标签库名称 可以添加自己的标签库,多个使用逗号分隔 
"TAGLIB_PRE_LOAD"     =>'',   //预先加载的标签库,无需在每个模板使用 taglib标签加载, 多个使用逗号分隔
"TAG_NESTED_LEVEL"    =>3     //标签嵌套级别

//-------------------------------------------------------------------------
//应用配置
//------------------------------------------------------------------------------
"APP_GROUP_DEPR"      =>'.',  //模块分组之间的分割符
"APP_GROUP_LIST"      =>'',   //项目模块分组列表,多个组之间用逗号分隑,例如 'Admin,Home'
"APP_CONFIG_LIST"     =>array('taglibs','routes','tags','htmls','modules','actions'),  //项目扩展配置文件列表
"APP_DOMAIN_DEPLOY"   =>false,    //是否使用独立域名部署项目,只有在项目目录本身就是网站根目录的情况下开启

//-------------------------------------------------------------------------
//URL配置
//------------------------------------------------------------------------------
"URL_MODEL"           =>1,   //URL模式: 普通模式 1 PATHINFO 2 REWRITE 3 兼容模式 当URL_DISPATCH_ON开启后有效 
                             //默认为PATHINFO 模式,提供最好的用户体验和 SEO支持 
        
"URL_PATHINFO_MODEL"  =>2,   //PATHINFO 模式,默认采用智能模式 
                             //普通模式参数没有顺序/m/module/a/action/id/1 
                             //智能模式制动识别模块和操作/module/action/id/1/ 或者 /module,action,id,1/...
        
"URL_PATHINFO_DEPR"   =>'/', //PATHINFO参数之间分割号 
"URL_ROUTER_ON"       =>true,   //是否开启URL路由 
"URL_HTML_SUFFIX"     =>'.av',   //伪静态后缀设置,例如 .shtml 
"URL_CASE_INSENSITIVE"  =>false, //URL是否不区分大小写,默认区分大小写


//------------------------------------------------------------------------------
//日志配置
//------------------------------------------------------------------------------
"LOG_RECORD"          =>false,  //是否记录网站日志,默认不记录日志 
"LOG_RECORD_LEVEL"    =>array('EMERG','ALERT','CRIT','ERR'),  //允许记录的日志级别
"LOG_FILE_SIZE"       =>2097152,  //日志文件大小限制, 针对文件方式的日志记录,超过会自动生成备份文件


//------------------------------------------------------------------------------
//错误配置
//------------------------------------------------------------------------------
"ERROR_MESSAGE"       =>'您浏览的页面暂时发生了错误!请稍后再试~',   //错误显示信息 非调试模式有效 
"ERROR_PAGE"          =>'',  //错误定向页面,需要填写完整的URL地址


//------------------------------------------------------------------------------
//数据库配置
//------------------------------------------------------------------------------
"DB_CHARSET"          =>'utf8',   //数据库编码,默认采用 utf8 
"DB_DEPLOY_TYPE"      =>0,        //数据库部署方式 :集中式(单一朋务器) 分布式(主从朋务器) 
"DB_RW_SEPARATE"      =>false,    //数据库读写是否分离,分布式数据库方式下面有效 
"DB_FIELDS_CACHE"     =>true,     //开启数据表字段缓存 
"DB_TYPE"             =>'mysql',  //数据库类型 
"DB_HOST"             =>'localhost',  //数据库服务器地址
"DB_NAME"             =>'',       //数据库名称 
"DB_USER"             =>'root',   //数据库用户名 
"DB_PWD"              =>'',       //数据库 密码 
"DB_PORT"             =>3306,     //数据库使用的端口 
"DB_PREFIX"           =>'think_', //数据库癿表前缀 
"DB_SUFFIX"           =>'',       //数据库的表后缀 
"DB_FIELDTYPE_CHECK"  =>false,    //是否迕行字段类型检查


//------------------------------------------------------------------------------
//静态缓存配置
//------------------------------------------------------------------------------
"HTML_FILE_SUFFIX"    =>'.shtml',  //默认静态文件后缀 
"HTML_CACHE_ON"       =>false,     //默认关闭静态缓存 
"HTML_CACHE_TIME"     =>60,        //静态缓存有效期 
"HTML_READ_TYPE"      =>1,         //静态缓存读取方式 0 readfile 1 redirect


//------------------------------------------------------------------------------
//数据缓存配置
//------------------------------------------------------------------------------
"DATA_CACHE_TYPE"     =>'File',     //数据缓存类型 支持 File Db Apc Memcache Shmop Sqlite Xcache Apachenote Eaccelerator 
"DATA_CACHE_PATH"     =>TEMP_PATH   //缓存路径设置 (仅对File方式缓存有效
"DATA_CACHE_TIME"     =>-1,         //数据缓存有效期 
"DATA_CACHE_COMPRESS" =>false,      //数据缓存是否压缩缓存 
"DATA_CACHE_CHECK"    =>false,      //数据缓存是否校验缓存 
"DATA_CACHE_SUBDIR"   =>false,      //使用子目录缓存 (自动根据缓存标识的哈希创建子目录
"DATA_PATH_LEVEL"     =>1,          //子目录缓存级别


//------------------------------------------------------------------------------
//运行时间配置
//------------------------------------------------------------------------------
"SHOW_RUN_TIME"       =>false,      //运行时间显示 
"SHOW_ADV_TIME"       =>false,      //显示详细的运行旪间,SHOW_RUN_TIME开启后有效 
"SHOW_DB_TIMES"       =>false,      //显示数据库读写次数 
"SHOW_CACHE_TIMES"    =>false,      //显示缓存读写次数 
"SHOW_USE_MEM"        =>false,      //显示内存开销 
"SHOW_PAGE_TRACE"     =>false,      //显示页面Trace信息 由 Trace文件定义和Action操作赋值 
"SHOW_ERROR_MSG"      =>true,       //发生错误时显示错误信息


//------------------------------------------------------------------------------
//Cookie设置
//------------------------------------------------------------------------------
"COOKIE_EXPIRE"       =>3600,       //Coodie有效期 
"COOKIE_DOMAIN"       =>'',         //Cookie有效域名 
"COOKIE_PATH"         =>'/',        //Cookie路径 
"COOKIE_PREFIX"       =>'',         //Cookie前缀 避免冲突

 

//-------------------------------------------------------------------------
//令牌验证配置
//------------------------------------------------------------------------------
"TOKEN_ON"            =>true,       //是否开启令牌验证 
"TOKEN_NAME"          =>'__hash__', //令牌验证的表单隐藏字段名称 
"TOKEN_TYPE"          =>'md5',      //令牌验证哈希规则


//------------------------------------------------------------------------------
//默认值配置
//------------------------------------------------------------------------------
"DEFAULT_APP"         =>'@',      //默认模型类所在的项目名称 表示当前项目 
"DEFAULT_GROUP"       =>'Home',   //默认分组 
"DEFAULT_MODULE"      =>'Index',  //默认模块名称 
"DEFAULT_ACTION"      =>'index',  //默认操作名称 
"DEFAULT_THEME"       =>'default',//默认模板主题名称 
"DEFAULT_LANG"        =>'zh-cn',  //默认语言 
"DEFAULT_TIMEZONE"    =>'PRC',    //默认时区 
"DEFAULT_AJAX_RETURN" =>'JSON',   //AJAX 数据返回格式 JSON XML ... 
"DEFAULT_CHARSET"     =>'utf-8',  //默认页面输出编码


//------------------------------------------------------------------------------
//系统变量配置
//------------------------------------------------------------------------------
//下面这些变量配置主要用于URL的特殊传值,在项目中的URL和表单参数尽量不要与之冲突,否则容易造成错误。 
"VAR_PATHINFO"        =>'s',   //PATHINFO 兼容模式获取变量例如 ?s=/module/action/id/1  
"VAR_GROUP"           =>'g',   //默认分组发量 
"VAR_ROUTE"           =>'r',   //默认路由获取变量 
"VAR_MODULE"          =>'m',   //默认模块获取变量 
"VAR_ACTION"          =>'a',   //默认操作获取变量 
"VAR_PAGE"            =>'p',   //默认分页跳转变量 
"VAR_TEMPLATE"        =>'t',   //默认模板切换变量
"VAR_LANGUAGE"        =>'l',   //默认语言切换变量 
"VAR_AJAX_SUBMIT"     =>'ajax',  //默认的AJAX提交变量

 

//-------------------------------------------------------------------------
//语言和时区
//------------------------------------------------------------------------------
"LANG_SWITCH_ON"      => false   //是否开启多语言功能,默认关闭

);
?>

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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

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)

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

How to adjust window border settings on Windows 11: Change color and size How to adjust window border settings on Windows 11: Change color and size Sep 22, 2023 am 11:37 AM

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

How to change title bar color on Windows 11? How to change title bar color on Windows 11? Sep 14, 2023 pm 03:33 PM

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

OOBELANGUAGE Error Problems in Windows 11/10 Repair OOBELANGUAGE Error Problems in Windows 11/10 Repair Jul 16, 2023 pm 03:29 PM

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

How to enable or disable taskbar thumbnail previews on Windows 11 How to enable or disable taskbar thumbnail previews on Windows 11 Sep 15, 2023 pm 03:57 PM

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

Display scaling guide on Windows 11 Display scaling guide on Windows 11 Sep 19, 2023 pm 06:45 PM

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

See all articles