Load_trait: Fast import traits,php5.5 above without calling
/**
* Fast import traits PHP5.5 above without calling
* @param string $class Trait Library
* @param string $ext class library suffix
* @return Boolean
*/
Load_trait ($class, $ext = ext)
Exception: Throwing exception handling
/**
* Throw exception Handling
* @param string $MSG Exception message
* @param integer $code exception code defaults to 0
* @param string $exception Exception class
*
* @throws Exception
*/
Exception ($msg, $code = 0, $exception = ")
Debug: Recording time (microseconds) and memory usage
/**
* Recording time (microseconds) and memory usage
* @param string $start start tag
* @param string $end end tag
* @param integer|string $dec decimal Place if m indicates statistics memory consumption
* @return Mixed
*/
Debug ($start, $end = ", $dec = 6)
Lang: Get the language variable value
/**
* Get language variable values
* @param string $name language variable name
* @param array $vars dynamic variable values
* @param string $lang language
* @return Mixed
*/
Lang ($name, $vars = [], $lang = ")
Config: Get and set configuration parameters
/**
* Get and set configuration parameters
* @param string|array $name The name of the parameter
* @param mixed $value parameter values
* @param string $range scope
* @return Mixed
*/
Config ($name = ", $value = null, $range =")
Input: Get inputs, support default values and filter
/**
* Get input data support default values and filtering
* @param string $key gets the variable name
* @param mixed $default default value
* @param string $filter filtering method
* @return Mixed
*/
Input ($key = ", $default = null, $filter = NULL)
Widget: Render Output widget
/**
* Render Output Widget
* @param string $name widget name
* @param array $data parameters passed in
* @return Mixed
*/
Widget ($name, $data = [])
Model: Instantiate model
/**
* Instantiate model
* @param string $name model name
* @param string $layer business layer Name
* @param bool $appendSuffix Add class name suffix
* @return \think\model
*/
Model ($name = ", $layer = ' model ', $appendSuffix = False)
Validate: Instantiating validators
/**
* Instantiation Validator
* @param string $name validator Name
* @param string $layer business layer Name
* @param bool $appendSuffix Add class name suffix
* @return \think\validate
*/
Validate ($name = ", $layer = ' Validate ', $appendSuffix = False)
DB: Instantiating a database class
/**
* Instantiating database classes
* Data table name @param string $name operation (without prefix)
* @param array|string $config Database configuration parameters
* @param bool $force whether forced reconnection
* @return \think\db\query
*/
db ($name = ", $config = [], $force = True)
Controller: Instantiating controllers, Format: [Module/] Controller
/**
* Instantiation Controller format: [module/] Controller
* @param string $name resource Address
* @param string $layer control layer Name
* @param bool $appendSuffix Add class name suffix
* @return \think\controller
*/
Controller ($name, $layer = ' Controller ', $appendSuffix = False)
Action: Invoke the module's action method, parameter format: [module/controller/] operation
/**
* Call Module action method parameter format [module/controller/] operation
* @param string $url call Address
* @param string|array $vars Call parameters support strings and arrays
* @param string $layer The name of the control layer to invoke
* @param bool $appendSuffix Add class name suffix
* @return Mixed
*/
Action ($url, $vars = [], $layer = ' Controller ', $appendSuffix = False)
Import: Imports the required class library, with the import of Java, this function has the cache function
/**
* Import the required class library with Java Import This function has the cache function
* @param string $class Class library namespace strings
* @param string $BASEURL start path
* @param string $ext imported file name extensions
* @return Boolean
*/
Import ($class, $baseUrl = ", $ext = ext)
Vendor: Fast import of third-party framework class library, all third-party framework's class library files are put into the vendor directory of the system.
/**
* Fast import of third-party framework class library all third-party framework class library files are placed under the vendor directory of the system.
* @param string $class class Library
* @param string $ext class library suffix
* @return Boolean
*/
Vendor ($class, $ext = ext)
Dump: Browser-friendly variable output
/**
* Browser-friendly variable output
* @param mixed $var variables
* @param boolean $echo whether the output defaults to True if False returns the output string
* @param string $label tag is empty by default
* @return void|string
*/
Dump ($var, $echo = true, $label = null)
Url:url generation
/**
* URL Generation
* @param string $url routing Address
* @param string|array $vars variables
* URL suffix generated by @param bool|string $suffix
* @param bool|string $domain domain name
* @return String
*/
URL ($url = ', $vars = ', $suffix = true, $domain = False)
Session:session Management
/**
* Session Management
* @param string|array $name session name, if the array represents the session setting
* @param mixed $value Session value
* @param string $prefix prefix
* @return Mixed
*/
Session ($name, $value = ", $prefix = null)
Cookie:cookie Management
/**
* Cookie Management
* @param string|array $name cookie name, if the array represents a cookie setting
* @param mixed $value cookie value
* @param mixed $option parameters
* @return Mixed
*/
Cookie ($name, $value = ", $option = null)
Cache: Caching Management
/**
* Cache Management
* @param mixed $name cache name if the array represents cache settings
* @param mixed $value Cache value
* @param mixed $options cache parameters
* @param string $tag cache tags
* @return Mixed
*/
Cache ($name, $value = ", $options = null, $tag = NULL)
Trace: Logging Information
/**
* Log information is logged
* @param mixed $log log information support strings and arrays
* @param string $level log level
* @return Void|array
*/
Trace ($log = ' [think] ', $level = ' log ')
Request: Get the current Request object instance
/**
* Get the current Request object instance
* @return Request
*/
Request ()
Response: Creating an ordinary Response object instance
/**
* Create a generic Response object instance
* @param mixed $data output data
* @param int|string $code Status code
* @param array $header header information
* @param string $type
* @return Response
*/
Response ($data = [], $code = $, $header = [], $type = ' html ')
View: render template Output
/**
* Render Template Output
* @param string $template template file
* @param array $vars template variable
* @param array $replace template replacement
* @param integer $code status code
* @return \think\response\view
*/
View ($template = ", $vars = [], $replace = [], $code = 200)
JSON: Getting a JSON object instance
/**
* Get \think\response\json Object instance
* @param the data returned by the mixed $data
* @param integer $code status code
* @param array $header head
* @param array $options parameters
* @return \think\response\json
*/
JSON ($data = [], $code = $, $header = [], $options = [])
JSONP: Get Jsonp Object instance
/**
* Get \think\response\jsonp Object instance
* @param the data returned by the mixed $data
* @param integer $code status code
* @param array $header head
* @param array $options parameters
* @return \think\response\jsonp
*/
JSONP ($data = [], $code = $, $header = [], $options = [])
XML: Getting an instance of an XML object
/**
* Get \think\response\xml Object instance
* @param the data returned by the mixed $data
* @param integer $code status code
* @param array $header head
* @param array $options parameters
* @return \think\response\xml
*/
XML ($data = [], $code = $, $header = [], $options = [])
Redirect: Get Redirect Object instance
/**
* Get \think\response\redirect Object instance
* Address of Url::build method supported by @param mixed $url redirect Address
* @param array|integer $params Additional parameters
* @param integer $code status code
* @return \think\response\redirect
*/
Redirect ($url = [], $params = [], $code = 302)
Abort: Throws an HTTP exception
/**
* Throwing HTTP Exceptions
* @param integer| Response $code Status Code or Response object instance
* @param string $message error message
* @param array $header parameters
*/
Abort ($code, $message = null, $header = [])
Halt: Debugging variables and interrupting output
/**
* Debug variables and interrupt output
* @param mixed $var Debug variables or information
*/
Halt ($var)
Token: Generate form Token
/**
* Generate form Tokens
* @param string $name token name
* @param mixed $type token generation method
* @return String
*/
Token ($name = ' __token__ ', $type = ' MD5 ')
thinkphp 5 Common helper functions