This article summarizes the string-handling functions of thinkphp and other common functions that can be used by developers for reference. Details are as follows:
Get the IP address of the client
Msubstr ($str, $start =0, $length, $charset = "Utf-8″, $suffix =true)
$STR: the string to intercept
$start = 0: Start position, starting from 0 by default
$length: Intercept length
$charset = "Utf-8″: Character encoding, default UTF-8
$suffix =true: If an ellipsis is displayed after the truncated character, the default is true to show that false is not displayed
Chinese string interception:
Call the following
{$vo. title|msubstr=5,5, ' Utf-8′,false}
Explanation: Intercept the string $vo.title, starting with the 5th character, intercept 5, encode as UTF-8, do not display the ellipsis
Generate Random strings
Type is random, including:
0 Letter 1 Digit 2 Capital Letter 3 Lowercase Letter 4 Chinese 5 Mix (remove easily confusing characters Ooll and number 01)
Addchars attached string
Create a random verification code, the mode parameter usage is consistent with the type of rand_string
Byte formatting the easy-to-understand size described by the byte number format as B K M G T
Detects if a string is UTF8 encoded
Code highlighting
Output Secure HTML code
Basic UBB Analysis
Randomly generate a set of strings
Remove XSS attacks in HTML code
The data set of the query is converted into a tree list array, the list represents the data set (array) of the query, PK denotes the primary key name, the PID represents the parent key name, the child represents the name of the sub-list, and the default is the _child,root represents the primary key value of the node.
Sort the dataset for the query, list represents the result DataSet (array) of the query, field represents the name of the fields to sort, sortby represents the sort type, including ASC forward sort desc Reverse sort Nat Natural Sort, default ASC
Search data in the query DataSet, list represents the result DataSet (array) of the query, condition represents the query criteria, support the following query methods
Array mode such as Array (' var1 ' = ' value1 ', ' var2 ' = ' value2 ') and supports regular expression array (' name ' = ' = '/[a-z]/')
Url method such as Var1=value1&var2=value2
Sends HTTP status information, status indicates HTTP status value, for example 302, 404