: This article mainly introduces Thinkphp entry 4-layout, cache, and system variables (48). For more information about PHP tutorials, see. [Controller operation method parameter settings]
Http: // URL/index. php/controller/operation method
Page jump]
Variable regulator]
Smarty variable regulator
TP variable regulator: common php functions (count strlen str_replace)
Definition: The output of the former is the input of the latter.
[Subtemplate inclusion]
The current module contains each other
[Use layout]
1. enable layout and configure variable information config. php
2. create the layout file Tpl/home/layout.html
3. do not use layout {__ NOLAYOUT __}
Layout Group
Home admin
A. Each group has its own configuration file config. php.
B. enable the layout function for each layout file
C. set the layout file for each group
Tp/home/layout.html
Tpl/admin/layout.html
Use custom layout
Note:
1. enable the layout function and set config. php to differentiate different groups.
2.make it clear that every page request will go to the layout file layout.html first.
[Cache usage of tp framework]
Cache variable information (common variables, arrays, objects ),
Cache static html content, cache part or all
Most of our data is obtained from the mysql database.
Cache medium: Memory (memcache), files (solving the database), cache to the database
The data is optimized and stored in the database.
File cache of the tp framework (shortcut function ):
A) set S (name, value)
B) read S (name)
C) delete S (name, null)
1. you can set cache files to different directories for storage.
This prevents a directory from storing too many cached files, affecting performance.
Effect:
2 Cache validity period
S (name, value, time );
3. cache settings
4 cache usage:
5. cache deletion
6 cache use cases
System variables]
Use all variables $ _ GET $ _ POST $ _ SESSION $ _ COOKIE in the template.
Constant usage:
$ Think. const. constant name
$ Think. get. name
Get configuration variable information in the template config. php
$ Think. config. name
Get configuration variable information in the controller
C (name); // shortcut function
Original output literal label]
The above introduces Thinkphp entry 4-layout, cache, system variable (48), including some content, hope to be helpful to friends who are interested in PHP tutorials.