Thinkphp Study Review (ii) the configuration of the config.php

Source: Internet
Author: User
Tags dsn

Common Configuration Items

<?

Return Array (

‘Configuration Items' = 'Configuration Values'
' Tmpl_l_delim ' = ' <{',//Modify the left delimiter to prevent it fromJSthe code in is coincident, causing the problem' tmpl_r_delim ' = '}> ',//Modify Right delimiter(Focus)
' Db_prefix ' = ' tp_ ',//Setdatabase table prefixes facilitate management of classifications (Focus)
' Db_dsn ' = ' mysql://root: @localhost: 3306/thinkphp3 ',/* useDSNConfigurationLink Database Information (Focus)It means that the use isMySQLdatabase file, user name isRootin the middle: separated, the password is empty, so omitted,@followed by the server name, followed by a colon3306port number, with/the last item that is separated is the database name(Focus). */
' Show_page_trace ' =>true,//turn on page trackingFor easy checking of SQLexecution of the statement(Focus)
' Tmpl_parse_string ' =>array (
' __css__ ' =>__root__. ' /public/css ',
' __js__ ' =>__root__. ' /public/js ',
' __images__ ' =>__root__. ' /public/images ',
),/*This is the definition of the replacement rule, like the above definition, can be used directly on the foreground page__css__instead of from the project file name toCssThe full path to this folder__root__is the template substitution rule, is to find the project folder path, such as your project calledBBS, then he will find the name of the project folder instead of you, even if you change the name of the project folder later you use__root__there is no error after substitution, it will be modified by default, more template replacement rules, see the article at the bottom of the note*/
);

?>

With the above configuration, usually a project can be completed, unless you want to change the pattern, then you can refer to the following configuration code

<?php
Return Array (
' config item ' = ' config value '
' Url_pathinfo_depr ' = '/',// This is to modify the PATHINFO mode in the address input of the slash to other symbols, default to /, can not write
' Tmpl_l_delim ' = ' <{',// modify left delimiter to prevent it from coincident with JS code, causing problems

' Tmpl_r_delim ' = '}> ',//Modify Right delimiter
/* ' db_type ' = ' mysql ',//Database Type//7-13is the configuration of the database,but it's too much trouble, so discard it.
' db_host ' = ' localhost ',//setting up a host
' Db_name ' = ' thinkphp ',//Set database name
' Db_user ' = ' root ',//Set user name
' Db_pwd ' and ' = ',//Set Password
' Db_port ' = ' 3306 ',//set the port number*/
' Db_prefix ' = ' tp_ ',//Set Table Prefixes
' Db_dsn ' = ' mysql://root: @localhost: 3306/thinkphp3 ',//UseDSNConfigure Database Information, you can complete the above database configuration tasks in one sentence
' Show_page_trace ' =>true,//turn on page tracking
' Db_like_fields ' = ' title|content '//in the query statementtitlefield conditions such as content automatically become fuzzy queries%%。
' Tmpl_tmplate_suffix ' = '. html ',//change file suffix, default isHTML, you can set other things like. TPL
' Tmpl_file_depr ' = ' _ ',//Changing the directory structure willThe TPL folder is changed to the formIndex_indexthe form, such as by indexfolder under theindex.htmlintoindex_index.htmlit can be used.
/*
*It's a theme .All 3 of the templatesItemsConfiguration, we temporarily shut down
' Default_theme ' = ' my ',//Set the default template theme tomy
' Tmpl_detect_theme ' =>true,//set automatic detection to automatic
' Theme_list ' = ' my,your ',//set up a list of all supported templates
*/
' Layout_on ' =>true,//automatically turn on template rendering
' Url_case_insensitive ' =>true,//url Case insensitive
' Url_html_suffix ' = ' html|shtml|xml ',//limit pseudo-static suffix names
' Tmpl_parse_string ' =>array (
' __css__ ' =>__root__. ' /public/css ',
' __js__ ' =>__root__. ' /public/js ',
' __images__ ' =>__root__. ' /public/images ',
),//This is the definition of the substitution rule.
//Configure Routing
' Url_router_on ' =>true,//Turn on routing
/*
* 1.Rule Routing
' Url_route_rules ' =>array (
' My ' = ' index/index ',//Usemyin the route instead ofIndex/index: Static Address Routing
': id/:num ' = ' index/index ',//Dynamic Address Routing:Id,num These values can be passed in
' year/:year\d/:month/:d ay$ ' = ' index/index ',//dynamic static hybrid routing the first one Yearis static
//If you add\dso that means it can only be numbers, letters or other errors.
Regular in ^to start,At the end, add a$that means the end,It's not going to add anything else.

),//set up routing rules
*/
/*
*Regular Routing
* */
' Url_route_rules ' =>array (
'/^year\/(\d{4}) \ (\d{2})/(\d{2}) $/' = ' index/index?year=:1&month=:2&day=:3 ',
//when multiple rules are juxtaposed, the complex is placed on top, this is the URL of the regular, meaning that the first item can only be4bits of the number,/parsing, the above code implements the date of the month passedURL
),

);
?>

Note:

Default Template substitution rules:

__public__ : The common directory that will be replaced with the current site is usually /public/

__root__ : Will replace the address of the current website (excluding domain name)

__app__ : Will replace the URL address of the current project (excluding domain name)

__url__ : Will replace the URL address of the current module (excluding domain name)

__ACTION__ : Will replace the current operation's URL address (without domain name)

__self__ : Will replace the current page URL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.