This article mainly introduces about the PHP source two: About Strlen, Strtolower, Strtoupper, Ord, Chr function, has a certain reference value, now share to everyone, there is a need for friends can refer to
int strlen (String string)
Returns the length of a string
There is no relevant implementation in the standard extension, using Z_strlen, Z_strlen_p, or z_strlen_pp in other extension functions to get the length
String Strtolower (String str)
Turns a string into lowercase, which implements the following code
"Classic Source Code"
Char *php_strtolower (char *s, size_t len) { unsigned char *c, *e; c = S; e = C+len; while (C < e) { *c = ToLower (*c); C + +; } return s;}
This is a simple program that iterates through the strings and turns each character into lowercase, but this is a standard use of pointers.
String Strtoupper (String string)
Turn a string into uppercase
The code implementation is similar to the above program just to turn the ToLower function into a toupper
string chr (int ascii)
Returns a single character that corresponds to the specified ASCII.
Its essence is to return a string of length 1
"Source Code"
Temp[0] = (char) z_lval_pp (num); TEMP[1] = 0; Retval_stringl (temp, 1, 1);
int ord (String string)
Returns the ASCII value of a character
It is essentially the ASCII value that returns the first character of a string
"Source Code"
Return_long ((unsigned char) z_strval_pp (str) [0]);
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!