Tp_ Letter function

Source: Internet
Author: User

1. A ()

A function for instantiating a controller

Format: [Resource://][module/] Controller A ($name, $layer = ", $level =")

@param string $name Resource Address

@param string $layer Control layer Name

@param integer $level Controller hierarchy

@return Controller|false

2. B ()

Executes a behavior B ($name, $tag = ',& $params =null)

@param string $name behavior name

@param string $tag tag name (the behavior class does not need to be passed in)

@param Mixed $params parameters passed in @return void

This is the new function that comes with behavior, which can perform a behavior, such as B (' App_begin ');

is to execute all functions defined by this behavior before the start of the project, support 2 parameters, and the second parameter supports the need to accept an array

such as B (' App_begin ', Array ("name" = "Tdweb", "Time" =>time ()));

3. C ()

Read and set configuration Parameters C ($name =null, $value =null, $default =null)

@paramstring |array $name Configuration variables

@param mixed $value configuration values

@param mixed $default Default value

@return Mixed

Get Value:

Get all settings: C (); Returns an array containing all the settings, without passing any arguments.

Get the specified configuration: C (' Url_model ') so that you can get Url_model configuration information

Gets the specified two-dimensional array configuration: C ("Array.name"), which returns the value corresponding to the name of the key under array

Set the value:

Assign a value of C ("Array.name", "value") to a two-dimensional array, the same principle (get the value of Array.name), and the value behind

Batch assignment:

$test =array ("Url_model" =>1, "Thin_model" =>true ");

C ($test); This will directly assign the values in the array.

To determine whether to assign a value:

C ("? Url_model ") to add a"? "to the front so that if the value is already assigned, it returns true

It should be noted that although the value of the configuration is changed here, but only this page has changed, to the next page will not work,

If you want to change it permanently, you need to match the F function to write the configuration file to config.php.

4. D ()

The D function is used to instantiate the model class format [resource://][module/] Model D ($name = ', $layer = ')

@param string $name Resource Address

@param string $layer model layer Name

@return Model

The D function has 2 advantages:

First, if the model has been instantiated before, then it is no longer instantiated, save resources;

Second, convenient debugging, if the model does not exist, will throw a TP anomaly, very humane.

If you access the Model direct D ("model name") of this project, then you can use D ("model name", "project name") if you intend to access across projects;

5. E ()

Throw exception Handling E ($msg, $code =0)

@param string $MSG Exception message

@param integer $code exception code defaults to 0

@return void

6. F ()

Fast file data reading and saving for simple type data strings, array F ($name, $value = ", $path =data_path)

@param string $name Cache name

@param mixed $value Cache value

@param string $path Cache path

@return Mixed

Quickly save the data: F ("MyData", "Here is the data to be saved"), so that a file named mydata.php is stored in the project data directory, the contents of which is the second parameter of the function.

Specify save time: F ("MyData", "Here is the data to be saved", "60"), so that if the next time you visit, the interval is greater than 60 seconds to delete the secondary cache file.

Specify Save directory: F ("MyData", "Here is the data to be saved", "" "," Data_path "), so it is specified to be saved in the data directory

Delete the cache now: F ("MyData", null), the second parameter passes a null value, so the mydate cache is deleted

Read the cached data: F ("MyData") so that the cache is read

7. G ()

Logging and Statistics time (microseconds) and memory usage G ($start, $end = ", $dec =4)

How to use:

G (' begin '); Record start tag bit//... Interval Run code

G (' End '); Record end tag Bit

echo G (' Begin ', ' End ', 6); Statistics interval run time is accurate to 6 digits after decimal

echo G (' Begin ', ' End ', ' m '); Statistical interval memory Usage if the end tag bit is not defined, it is automatically marked as the current mark bit

Where statistical memory usage requires MEMORY_LIMIT_ON constant is true only valid

@param string $start start tag

@param string $end end tag

@paraminteger |string $dec decimal digits or M

@return Mixed

8. I ()

Get input parameters support filtering and default value I ($name, $default = ' ', $filter =null)

How to use:

I (' id ', 0); Get ID parameter automatically determine get or post

I (' Post.name ', ', ' Htmlspecialchar s '); Get $_post[' name ']

I (' get. '); Get $_get

9. L ()

Get and set language definitions (case insensitive) L ($name =null, $value =null)

@paramstring |array $name Language variables

@param mixed $value language values or variables

@return Mixed

The language definition function, L ("Intro") gets the language defined as intro, L ("Intro", "Introduction") assigns a value to intro

Ten. M ()

The M function is used to instantiate a model M ($name = "', $tablePrefix = ', $connection = ') without a modeling file

@param string $name model name supports specifying the underlying model such as Mongomodel:user

@param string $tablePrefix Table prefix

@param mixed $connection Database connection information

@return Model

One. N ()

Set and get Statistics N ($key, $step =0, $save =false)

How to use:

N (' db ', 1); Number of database operations logged

N (' read ', 1); Record number of reads

echo N (' db '); Get all operations for the current page database

echo N (' read '); Gets the current page read count

@param string $key Identify the location

@param integer $step Stepping value

@return Mixed

R ()

Action method for Remote call Controller URL parameter format [resource://][module/] Controller/Operation R ($url, $vars =array (), $layer = ")

@param string $url Call Address

@paramstring |array $vars Call parameters support strings and arrays

@param string $layer The name of the control layer to invoke

@return Mixed

T ()

Get template file Format resource://Module @ Theme/controller/operation T ($template = "', $layer =")

@param string $name template resource Address

@param string $layer view layer (directory) name

@return string

U ()

URL assembly supports different URL patterns U ($url = ', $vars = ', $suffix =true, $domain =false)

@param string $url URL expression, format: ' [module/controller/operation # Anchor @ domain name]? parameter 1= value 1& parameter 2= value 2 ... '

@paramstring |array $vars parameters passed in, supporting arrays and strings

@param string $suffix pseudo-static suffix, which by default is true to get the configuration value

@paramboolean $domain Whether the domain name is displayed

@return string

How to use:

Get the action address of the current module: U ("/nowmethod");

Get the action address of the current module and pass the parameter: U ("/nowmethod?params=test");

(If you are not accustomed to the way above, you can use the U ("/nowmethod", Array ("params" = "test"), such an array way to pass parameters, the effect is the same)

Ways to access other modules: U ("Other/othermethod"), which is to access the Othermethod method under the other module

Cross-Project Access: U ("Appname://other/othermethod");

Use Routing access: U ("Appname://[email protected]/actionname?params");

In addition, if you want to jump directly, then in the second parameter write 1, such as U ("/nowmethod", 1), so that the direct switch to the specified URL

. W ()

Render Output widget W ($name, $data =array ())

@param string $name widget name

@param array $data parameters passed in

@return void

S ()

Cache Management S ($name, $value = ", $options =null)

@param mixed $name Cache name if the array represents cache settings

@param mixed $value Cache value

@param mixed $options Cache parameters

@return Mixed

The global cache read-write function, like C, is just written directly to the file, written in the temp directory, but in the cache there is a point to note

If the cache name is AAA, then the file name generated by the cache is the value of MD5 ("AAA").

Tp_ Letter function

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.