Home  >  Article  >  Backend Development  >  Skillful Learning and Use: How to Use String Functions in PHP_PHP Tutorial

Skillful Learning and Use: How to Use String Functions in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:33:35820browse


 (1)echo, print, printf, sprintf
 
 The first two functions output strings. If there is a variable name in the string, it will be replaced with its value.
 
 The last two functions A function is similar to the C function of the same name. They are commonly used string manipulation functions, some of which have the same meaning as the functions of the same name in C.
 
 strrev is to flip a string.
 
The meanings of strtolower and strtoupper should not need to be explained.
 
 ucfirst is to capitalize the first character of the string.
 
 substr is to return a substring of the string. The usage is: substr (string, header, length).
 
 The head position is calculated from 0. If it is a negative number, it means counting forward from the tail. Function.
 
 (4)explode,implode,join
 
 These are functions related to arrays.
 
 explode (string, delimiter) returns a string that is The array generated by dividing at the separator.

implode (array, separator) returns a string formed by inserting the separator between each element of the array.

The meaning of join and implode Same as.
into their names, for example, "<" becomes "<". 🎜> 
 (8)AddSlashes, StripSlashes
 
 Add and remove "".
 
 (9) parse_str
 
 Parse strings of type "name1=value1&name2=value2&..." into some variables.
 
 
For example:

 parse_str("a=1&b =2");
 
Generate two variables $a and $b, with values ​​1 and 2 respectively.

If there are two pairs of names/values ​​with the same name part, then the latter one The value overwrites the previous one.
 
If the names of these two pairs have "[]" at the end, such as "a[]=1&a[]=2", then the array $a will be generated, and the two elements will be 1,2




http://www.bkjia.com/PHPjc/508606.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/508606.html

TechArticle(1) echo, print, printf, sprintf The first two functions are to output strings. If there is The variable name is replaced by its value. The latter two functions are similar to the C functions of the same name. (2) strchr, strlen, strto...





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