Strtoupper ():
1 php_function (strtoupper) 2 { 3 zend_string *str; 4 5 Zend_parse_parameters_start (11) 6 z_param_str (STR) 7 zend_parse_parameters_end (); 8 9 return_str (Php_string_toupper (STR)); Ten }
The main implementation in the Php_string_toupper () function:
1Phpapi zend_string *php_string_toupper (zend_string *s)2 {3UnsignedChar*c, *e;4 5c = (unsignedChar*) Zstr_val (s);//String Header address6E = C + Zstr_len (s);//address After the end of the string, pointing to the end of the string "\"7 8 while(C <e) {9 if(Islower (*C)) {//when the first lowercase character is encountered, it is entered into this if branch, and the operation of the following character will be done in this ifTenRegister unsignedChar*R; OneZend_string *res = Zend_string_alloc (Zstr_len (s),0);//Open Memory storage zend_string type data A - if(c! = (unsignedChar*) Zstr_val (s)) {//when C is not the first address of the string, perform this if -memcpy (Zstr_val (res), Zstr_val (s), C-(unsignedChar*) Zstr_val (s));//copy character data before C position to Res the } -R = C + (Zstr_val (res)-Zstr_val (s));//where to start the conversion - //An uppercase conversion operation is performed for each character in the following while - while(C <e) { +*r = ToUpper (*c); -r++; +C++; A } at*r =' /';//Add an end flag to a string - returnRes//returns a new string - } -C++; - } - returnZend_string_copy (s);//The original string is not manipulated, the original string is returned, and the reference +1 in}
Strtolower () is similar to it.
PHP built-in function Analysis Strtoupper (), Strtolower ()