Summary of php string related processing functions

 

 In PHP, one of the most dealing with strings is strings, so learning how to deal with strings will be more effective in the future development process. This article is a summary post of string-related functions, so that students can quickly find the tutorial and carry out the system. Learn.

1. String positioning search - strstr(), strpos(), use these two functions, if you want to quickly determine whether strpos() exists, see the tutorial on this site for detailed instructions and examples, the commonly used string search function strstr in php , strpos example explanation

2. The string interception operation mainly uses mb_substr() and mb_struct(), and you need to pay attention to Chinese operations. For detailed examples, see the tutorial on this site, mb_substr example explanation , mb_strcut example explanation

3. The measurement of string length mainly uses strlen() and mb_strlen(), one is measured by bytes, and the other is measured by characters. For detailed examples, see the tutorial on this site . The commonly used string length functions in php are strlen() and mb_strlen() example explanation

4. String case conversion - these functions are relatively simple. Examples of string case conversion functions commonly used in php are explained

5. The string comparison function, strcmp() , is very simple, just check it directly.

6. The string conversion function htmlspecialchars() is very important. It is mainly used to convert characters to HTML entities. Especially in database access operations, you must be careful. If you don’t have much to say, it is recommended to read carefully and operate them. Portal, php Detailed explanation of the string conversion function htmlspecialchars()

7. HTML tag filtering function - strip_tags(), a very important function. For detailed examples, see the tutorial on this site. Detailed explanation of string filtering strip_tags() function in php

8. String replacement function, the most efficient PHP function str_replace(), it is recommended to read and operate it carefully. Detailed explanation of the four usages of str_replace() in PHP string replacement

9. Example usage of PHP string trim() function, remove the leading and trailing blank characters, very simple, can be viewed directly, PHP string trim() function example usage

 

Summary: The above are related functions that are commonly used in the process of string manipulation in PHP. Due to time constraints, it is impossible to explain all the functions of the string. In fact, I understand the important functions, and I will add them later in the development process. That's it. It is recommended that the relevant code in the tutorial on this site is best to be tapped by hand. If you are lazy, please give up directly, it will not help you.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326771824&siteId=291194637