PHP built-in function Analysis Strtoupper (), Strtolower ()

Source: Internet
Author: User

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 ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.