Thinkphp Getting started four-layouts, caches, system variables (48)
"Controller action method parameter settings"
http://URL/index.php/Controller/operation method
"Page Jump"
"Variable Adjuster"
Smarty Variable Adjuster
TP variable adjuster: normal PHP function (Count strlen str_replace)
Definition: The output of the former is the input of the latter
"Child template contains"
Current modules contain each other
"Using layout layouts"
1. Open the layout and configure the variable information config.php
2. make layout file tpl/home/layout.html
3. Do not use layout {__nolayout__}
Layout grouping
Home Admin
A, each group has its own configuration file config.php
B. Set the layout opening function for each layout file
C, set the layout file for each group
Tp/home/layout.html
Tpl/admin/layout.html
Using the custom layout
Attention:
1. Open the layout function, set the config.php to be careful to distinguish different groups
2. We want to make it clear that once the layout is turned on, each page request will first go through the layout file layout.html
"TP Framework Cache use"
Cache variable information (normal variable, array, object),
Caching static HTML content, caching part or all
The most of our data is obtained from the MySQL database.
Cache Media: Memory (memcache), file (resolve database), cache to database
The data is optimized and stored inside the database.
File cache for TP framework (shortcut function):
A) Set S (name, value)
b) Read S (name)
c) Remove S (name, NULL)
1 You can set the cache file to a different directory to store
This prevents a directory from storing too many cache files, which can affect performance
Effect:
2 Cache Expiration
S (name, value, time);
3 Cache Settings
4 Cache Usage:
5 Cache deletion
6 Caching Use Cases
"System Variables"
Use all variables inside the template $_get $_post $_session $_cookie, etc.
Constants use:
$Think. Const. Constant name
$Think. Get. Name
Get configuration variable information inside the template config.php
$Think. config. name
Get configuration variable information inside the controller
C (name); Shortcut functions
"Output literal label as-is"