2015.1 Summary of knowledge points and functions, when writing a message board

Source: Internet
Author: User
2015.1 knowledge points and functions for writing the message board---> summary

One: Time function and Uniqid ()

1:uniqid (): Generates a unique ID, the length of the string returned by the parameterless parameter is 13, and the parameter is 23

2: PHP functions that convert time and time stamps to each other

①:time () returns the current UNIX timestamp microtime () returns the timestamp and number of microseconds

②:date (' y-m-d h:i:s ', Time ()) format a local date/date

③:strtotime () Converts the datetime description of the English text of any date to a Unix timestamp

Two: Jump and redirect of TP frame

1: Page Jump

①:success (' Cue message ', ' Jump address ', ' Jump Time '); Default Jump Address: $_server[' http_referer ') Default wait time: 1 seconds

②:error (' Cue message ', ' Jump address ', ' Jump Time '); Default Jump Address: Javascript:history.back (-1) Default wait time: 3 seconds

2: Redirect to page

Redirect (' URL address ', ' time ', ' hint message ') just want to redirect a specified URL address instead of a module's Operation method. is consistent with the use of the U function.

3:u () Generate URL

Define the rule: U (' address expression ', [' parameter '], [' pseudo static suffix '], [' Show domain Name ']);

Anchor Point Support

Three: Model definition of TP Framework (M,d method)

1: Direct instantiation

Model ([' model name '], [' Data table prefix '], [' Database connection Information ']); Can be instantiated in most cases without passing in any parameters

Connection information supports three formats

①: string definition

②: Array definition

③: Configuration definition

2: D Method Instantiation (instantiation of custom model Class)

When the ①:\home\model\usermodel class does not exist, the D method attempts to instantiate the \common\model\usermodel of the public module, if it does not exist, to instantiate the \think\model base class.

②:linux, note the case of the model name when the D method is instantiated

③: Model classes that automatically load public modules are not supported when instantiating model classes across modules

3:m Method Instantiation Model

①: Supports cross-Library operations

②: Default direct instantiation of the \think\model class, instantiating other common model classes: $user = M (' \home\model\commonmodel:user ', ' think_ ', ' db_config ');

③: If your model class has its own business logic, the M method is not supported, even if the specific model class has been defined, the M method will be ignored directly when instantiated

4: Instantiate an empty model class (only native SQL queries are required)

①:new Model ()

②:m ()

    

    D () and M () distinguish D to instantiate a specific model class, the model class that is not found will automatically call the M method

M is the basic curd operation of the data table, because the performance will be higher without the need to load the specific model class, no need to define the model class for each data table

IV: C () and I ()

1:C (' parameter name ') gets the parameter value that has already been set to return null

C (' parameter name ', ' new parameter value ') dynamic configuration assignment is valid only for the current request and will not affect future requests such as: dynamically changing the cache validity period

2:I (): Get system variables and user-submitted data

I (' Variable type ', ' variable name/modifier ', [' Default value '], [' Filter Method '], [' Extra data source ']) Note: The variable modifier is 3.2.3 version added

can support default values, method filtering (Htmlspecialchars: pre-defined strings to Entities, Strip_tags () functions: Stripping HTML, XML, PHP tags), getting the entire variable type

  

    

    

  

  • 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.