The previous article introduced you to "Do you know what a delimiter is? How do we define strings with delimiters? ? ? 》, this article continues to introduce you to the use of the string function library:
String processing includes:
String formatting, string splitting and concatenation, string comparison, search and replacement, string interception, filtering, string ASCII, encryption, etc.;
Processing methods : PHP string processing functions, regular expressions.
Regarding the use of the string function library, we demonstrate through code:
<?php $str = "欢迎来到PHP中文网"; //is_string //检验变量是否是字符串类型,是返回true,否则返回false if(is_string($str)){ echo $str; } echo "<hr>"; echo strlen($str);//strlen()返回字符串的长度 echo "<hr>"; echo strtoupper($str); ?>
The running results are as follows:
About strings, Let’s add one more thing: (use curly braces {} to add, delete, modify and check a string), the specific operation code is as follows:
<?php //使用花括号{}对一个字符串进行增删改查 $a = 'I LOVE '; echo $a{0}; //将字符串看成集合,可以通过在字符串之后使用{}指定所要的字符从0开始的偏移量来查看 echo "<br>"; $a{10}='Y'; echo $a; echo "<hr>"; $b = 'i love you'; $b{6} = 's'; echo $b; ?>
The running results are as follows:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How do you understand the use of the string function library? Let's discuss it together! ! !. For more information, please follow other related articles on the PHP Chinese website!