Thinkphp Getting started four-layouts, caches, system variables (48)

Source: Internet
Author: User
"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"

The above describes the introduction of thinkphp four-layout, caching, System variables (48), including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    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.