Php commonly used string operation functions & lt ;? Php $ str = & quot; Iamchinese, Ilovechina & quot; echostrlen ($ str ). & quot; & lt; br/& gt; & quot; // Obtain the string length. ech php is commonly used to operate on strings.
"; // Obtain the string length echo trim ($ str )."
"; // Remove the space echo strtolower ($ str )."
"; // Convert to lowercase echo strtoupper ($ str )."
"; // Convert to uppercase // case-insensitive comparison if (strcasecmp (" I am chinese, I love china "," I am chinese, I love china ") = 0) {echo "these two characters are case insensitive
";}// The first big value returns an integer // case-sensitive comparison switch (strcmp (" Admin ", 'admin') {// case 0: echo "two strings are equal
"; Break; case-1: echo" the first character is less than the second
"; Break; case 1: echo" the first character is greater than the second
"; Break;}/* strstr () function is case sensitive. The first parameter is the string to be acquired. The second parameter is the string to be acquired. if not, if the return value is false, the remaining part of the captured string is returned. it is mainly used to determine whether a string contains stristr (), which is different from strstr () is case insensitive */echo strstr ("this is test! "," Test ")."
"; // Test! /* Different from strstr (), the return result is the first occurrence location of the character seek. it is mainly used to determine whether the string seek contains stripos () and is not case sensitive. */echo strpos ("this is test! "," Test ")."
";/* Replace str_replace () case-sensitive php 5.0 and later support four parameters. The first object to be the target object is the character to be replaced. The second object to be replaced. the third object to be searched. The fourth object is the total number of str_ireplace times. () case insensitive */echo str_replace ("china", "CHINA", $ str, $ count )."
"; Echo" $ count times in total ";/* obtain a part of the substr (string, start, length) parameter description string is required. Specifies that a part of the string is to be returned. Start is required. Specifies where the string starts. Positive number-start negative number at the specified position of the string-Start 0 from the specified position at the end of the string-start length at the first character of the string. optional. Specifies the length of the string to be returned. The default value is until the end of the string. Positive number-return a negative number from the position of the start parameter-return */echo substr ("Hello world! ", 6, 5 )."
"; Echo substr (" hello world! ", 0 )."
"; Echo substr (" Hello world! ", 0,-1 )."
";?>