mirror of
https://github.com/php/php-src.git
synced 2024-11-25 10:54:15 +08:00
- MFH (lcfirst())
- Initial test for lcfirst
This commit is contained in:
parent
89871ecc54
commit
a3c09d611c
@ -2623,6 +2623,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_ucfirst, 0)
|
||||
ZEND_ARG_INFO(0, str)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_lcfirst, 0)
|
||||
ZEND_ARG_INFO(0, str)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
static
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_ucwords, 0)
|
||||
ZEND_ARG_INFO(0, str)
|
||||
@ -3148,6 +3153,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */
|
||||
PHP_FE(substr_replace, arginfo_substr_replace)
|
||||
PHP_FE(quotemeta, arginfo_quotemeta)
|
||||
PHP_FE(ucfirst, arginfo_ucfirst)
|
||||
PHP_FE(lcfirst, arginfo_lcfirst)
|
||||
PHP_FE(ucwords, arginfo_ucwords)
|
||||
PHP_FE(strtr, arginfo_strtr)
|
||||
PHP_FE(addslashes, arginfo_addslashes)
|
||||
|
@ -53,6 +53,7 @@ PHP_FUNCTION(strrchr);
|
||||
PHP_FUNCTION(substr);
|
||||
PHP_FUNCTION(quotemeta);
|
||||
PHP_FUNCTION(ucfirst);
|
||||
PHP_FUNCTION(lcfirst);
|
||||
PHP_FUNCTION(ucwords);
|
||||
PHP_FUNCTION(strtr);
|
||||
PHP_FUNCTION(strrev);
|
||||
|
@ -2646,6 +2646,36 @@ PHP_FUNCTION(ucfirst)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{
|
||||
Lowercase the first character of the word in a native string */
|
||||
static void php_lcfirst(char *str)
|
||||
{
|
||||
register char *r;
|
||||
r = str;
|
||||
*r = tolower((unsigned char) *r);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ucfirst(string str)
|
||||
Make a string's first character lowercase */
|
||||
PHP_FUNCTION(lcfirst)
|
||||
{
|
||||
char *str;
|
||||
int str_len;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!str_len) {
|
||||
RETURN_EMPTY_STRING();
|
||||
}
|
||||
|
||||
ZVAL_STRINGL(return_value, str, str_len, 1);
|
||||
php_lcfirst(Z_STRVAL_P(return_value));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ucwords(string str)
|
||||
Uppercase the first character of every word in a string */
|
||||
PHP_FUNCTION(ucwords)
|
||||
|
BIN
ext/standard/tests/strings/lcfirst.phpt
Normal file
BIN
ext/standard/tests/strings/lcfirst.phpt
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user