Home  >  Article  >  Backend Development  >  Explanation of several character processing functions in php_PHP tutorial

Explanation of several character processing functions in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:37:42756browse

String splitting and concatenation functions:

Code:
array explode(string delimiter, string data)
Use string dellimiter to split data into an array and return it
Similar functions: split()
Code:
string implode(array data, string dellimiter)
The function is exactly the opposite of explode(). It uses dellimiter to connect the array into a long string
Function alias: join()
Code:
array split(string pattern, string text[, integer limit])
Use characters matching pattern as delimiters to split the string text into arrays
limit optional parameter, limiting the number of segments
String encoding and decoding function:
Code:
string addslashes(string text)
Add "" before the special characters in the string text to return. Special characters include (), ("), ().
Similar functions: quotemeta()
Code:
string stripslashes(string text)
Just the opposite of addslashes() function, remove the backslash encoding
Code:
string quotemeta(string text)
Similar to addslashes(), the difference is that its special characters include: . + * ? [ ] ^ ( ) $
Code:
string escapeshellcmd(string command)
Add a backslash before any characters that may cause trouble in shell commands.
Used before exec(), system() and other functions.
Code:
string mysql_escape_string(string text)
Escape an SQL string to make it safe for use with mysql_query()
HTML related functions
Code:
string htmlentities(string text)
Convert all HTML entities
Code:
string htmlspecialchars (string string [, int quote_style [, string charset]])
Convert specific characters to HTML entities
quote_style: (ENT_COMPAT|ENT_QUOTES)
quote_style default value: ENT_COMPAT conversion& < >
When quote_style is: ENT_QUOTES, in addition to converting the above characters, " and
are also converted
Code:
string trim(string text)
Remove the null characters at the beginning and end of the string text
Code:
string ltrim(string text)
Remove the null character at the beginning of the string text
Code:
string rtrim(string text)
Remove the null character at the end of the string text
Code:
string chop(string text)
Alias ​​of function rtrim()

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486552.htmlTechArticleString splitting and connecting functions: Code: array explode(string delimiter, string data) Use string dellimiter to put data Split into an array and return a similar function: split() code...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn