Home > Backend Development > PHP Tutorial > Getting Started with Thinkphp 4—Layout, Cache, System Variables (48)

Getting Started with Thinkphp 4—Layout, Cache, System Variables (48)

WBOY
Release: 2016-08-08 09:22:50
Original
1212 people have browsed it

【Controller operation method parameter setting】

http://website/index.php/controller/operation method

【Page jump】

【Variable regulator】

Smarty variable Regulator

TP variable regulator: ordinary php function (count strlen str_replace)

Definition: the output of the former is the input of the latter

[Subtemplate inclusion]

The current modules include each other

                                                                                                                                                                                                    

【Use layout layout】

  1. Open the layout and configure the variable information config.php

 2. Production 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. Give each Layout file setting layout enable function
 c. Set layout files for respective groups
Tp/home/layout.html
Tpl/admin/layout.html

Use custom layout


Note:
1 . Turn on the layout function, and pay attention to distinguishing different groups when setting config.php
2. We must 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 usage]

cache Variable information (ordinary variables, arrays, objects),
cache static html content, cache part or all

Most of our data is obtained from the mysql database.

Cache media: memory (memcache), file (processing database), cache to database

The data is optimized and stored in the database.

tp framework’s file cache (shortcut function):
 a) Set S (name, value)
  b) Read S (name)
  c) Delete S (name, null)

1 You can give cache Set files to be stored in different directories

This can avoid storing too many cache files in one directory, which affects performance

Effect:

  2 Cache validity period

S (name, value, time);

  3 Cache settings

4 Cache usage:

5 Cache deletion

6 Cache usage cases

[System variables]

Use all variables $_GET in the template $_POST $_SESSION $_COOKIE etc.
Constant usage:
$Think.const.Constant name
$Think.get.Name

Get configuration variable information in the template config.php
$Think.config.Name

In control Get the configuration variable information in the browser
C (name); //Shortcut function


[Output the literal label as it is]

The above introduces Getting Started with Thinkphp Part 4 - Layout, Cache, System Variables (48), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template