Thinkphp entry 4-layout, cache, system variables (48)

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

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.