Php learning 2, php learning 2
<? Phpheader ("content-type: text/html; charset = UTF-8"); echo "hello"; function myEcho ($ string) {echo "<br> ". $ string ;}# functions for several string operations # trim (string str, [string charlist]) removes spaces at the beginning and end # charlist is an optional parameter that specifies the special character to be deleted # Itrim () like trim (), it removes the rtrim () on the left () remove the right # note that none of these two functions is removed. query and delete one or more myEcho ('$ ""') from the left and right sides ""'); # For single quotes strings, only the escape of single quotes is involved # php provides the Escape Character function # The addslashes () function is to add the Escape Character symbol # stripslahes () function is to remove the Escape Character symbol $ sr = "select * from sudent Where name = 'bitch' "; myEcho ($ sr); $ ss = addslashes ($ sr); myEcho ($ ss); $ sr = stripslashes ($ ss ); myEcho ($ sr); # string length strlen (string str) # string truncation substr (string str, int start [, int length]) # The length parameter is optional. If it is a negative number, it indicates the inverted number length # string comparison function # strcmp (string str1, string str2) case sensitivity: These two values are compared by byte # strcasecmp (string str1, string str2) is case insensitive # comparison by natural sorting # strnatcmp (string str1, string str2) # I don't quite understand what the sort is. # strncmp (string Str1, string str2, int len) # Another parameter len represents the length of the string to be compared # string matching # strstr (string haystack, string needle) function # strchr (string haystack, string needle) function from the end to find myEcho (strstr ("nishibitch", "bitch"); # output bitch is different from java # strstr_count (...) obtain the number of characters in the string myEcho (substr_count ("nishibitch", "bitch"); # replace the string str_ireplace (search, replace, subject [, int & count]) function # search string # string replaced by replace # the string to be replaced by subject # optional Replace several # sub_replace (str, replaceStr, start, len) # Replace the start character in the str string with the character after len to replaceStr # Format String number_format () # split string explode (separator, str [, int limit]) function # separator # str split string # limit can be divided into several strings at most # merged string Implode (string glue, array pleces) # What character is used for glue connection # The array to be connected by pleces $ rrrr = array ("1", "2", "@ 3", "@ 4 ", "5"); $ stringRrrr = Implode ("@", $ rrrr); myEcho ($ stringRrrr); $ rrrr = explode ("@", $ stringR Rrr); echo "<br> ". count ($ rrrr ). "<br>"; for ($ I = 0; $ I <sizeof ($ rrrr); $ I ++) {// count () sizeof () all feasible # code... echo $ rrrr [$ I] ;}?>