Ucfirst ($STR)
str
converts the first character (if the first character is a letter) to an uppercase letter, and returns the string.
Source is located in Ext/standard/string.c
1 /*{{{ php_ucfirst2 Uppercase the first character of the word in a native string*/3 Static voidPhp_ucfirst (Char*str)4 {5RegisterChar*R;6R =str;7*r = ToUpper ((unsignedChar) *R);8 }9 /* }}} */Ten One /*{{{proto string Ucfirst (String str) A makes a string ' s first character uppercase*/ - php_function (Ucfirst) - { theZend_string *str; - -Zend_parse_parameters_start (1,1) - z_param_str (STR) + zend_parse_parameters_end (); - + if(!Zstr_len (str)) { A return_empty_string (); at } - - Zval_stringl (Return_value, Zstr_val (str), Zstr_len (str)); - Php_ucfirst (z_strval_p (Return_value)); - } - /* }}} */
*r = ToUpper ((unsigned char) *R), this sentence invokes the C function ToUpper () to capitalize the first element of the character array.
The implementation of function Lcfirst () is similar to Ucfirst ().
PHP built-in function Analysis Ucfirst (), Lcfirst ()