thinkphp string function and general function summary _php instance

Source: Internet
Author: User
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

  • Related Article

    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.