php内置函数分析之ucfirst()、lcfirst()
ucfirst($str)
将 str 的首字符(如果首字符是字母)转换为大写字母,并返回这个字符串。
源码位于 ext/standard/string.c
/* {{{ php_ucfirst
Uppercase the first character of the word in a native string */
static void php_ucfirst(char *str)
{
register char *r;
r = str;
*r = toupper((unsigned char) *r);
}
/* }}} */
/* {{{ proto string ucfirst(string str)
Makes a string's first character uppercase */
PHP_FUNCTION(ucfirst)
{
zend_string *str;
ZEND_PARSE_PARAMETERS_START(, )
Z_PARAM_STR(str)
ZEND_PARSE_PARAMETERS_END();
if (!ZSTR_LEN(str)) {
RETURN_EMPTY_STRING();
}
ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str));
php_ucfirst(Z_STRVAL_P(return_value));
}
/* }}} */
*r = toupper((unsigned char) *r); 这句调用c函数toupper()将字符数组的第一个元素转为大写。
函数lcfirst()的实现与ucfirst()类似。
php内置函数分析之ucfirst()、lcfirst()的更多相关文章
- map内置函数分析所得到的思路
map:会根据提供的函数对指定序列做映射. map(func, *iterables) --> map object Make an iterator that computes the fun ...
- php内置函数分析之array_diff_assoc()
static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_type) /* {{{ */ { uint ...
- php内置函数分析之array_combine()
PHP_FUNCTION(array_combine) { HashTable *values, *keys; uint32_t pos_values = ; zval *entry_keys, *e ...
- php内置函数分析之ucwords()
PHP_FUNCTION(ucwords) { zend_string *str; char *delims = " \t\r\n\f\v"; register char *r, ...
- php内置函数分析之strtoupper()、strtolower()
strtoupper(): PHP_FUNCTION(strtoupper) { zend_string *str; ZEND_PARSE_PARAMETERS_START(, ) Z_PARAM_S ...
- php内置函数分析之trim()
官方手册中: 类似函数还有两个:ltrim() 和 rtrim().分别处理字符串的左侧.右侧. trim()的具体实现位于:ext/standard/string.c /* {{{ proto st ...
- php内置函数分析之str_pad()
PHP_FUNCTION(str_pad) { /* Input arguments */ zend_string *input; /* Input string 输入字符串*/ zend_long ...
- php内置函数分析之array_fill_keys()
PHP_FUNCTION(array_fill_keys) { zval *keys, *val, *entry; if (zend_parse_parameters(ZEND_NUM_ARGS(), ...
- php内置函数分析range()
PHP_FUNCTION(range) { zval *zlow, *zhigh, *zstep = NULL, tmp; , is_step_double = ; double step = 1.0 ...
随机推荐
- Windows10主机插入耳机只有一边有声音
Windows10主机插入耳机只有一边有声音 在网上看了好几个版本,排除了主机插孔和耳机本身的问题,根据一篇文章在声音设置中找到了答案,原文章不是windows10,所以我找了好一会才找到,所以特地写 ...
- 修改docker默认网段
一. 修改普通docker run启动的容器的网段 https://blog.51cto.com/13670314/2345518?source=dra https://blog.csdn.net/w ...
- hive三种方式区别和搭建
Hive 中 metastore(元数据存储)的三种方式: a)内嵌 Derby 方式 b)Local 方式 c)Remote 方式 第一种方式 ...
- (转) intellij idea部署web项目时的位置(Tomcat)
这篇文章说的比较好: 原文地址:https://blog.csdn.net/zmx729618/article/details/78340566 1.当你项目启动的时候console能看到项目运行的位 ...
- VMware 虚拟化编程(6) — VixDiskLib 虚拟磁盘库详解之二
目录 目录 前文列表 VixDiskLib 虚拟磁盘库 VixDiskLib_Open 打开 VMDK File VixDiskLib_Read 读取 VMDK File 数据 VixDiskLib_ ...
- Notepad++的tab设置为四个空格
参考:https://www.cnblogs.com/jyfootprint/p/9409934.html 1.Python使用缩进来组织代码块,坚持使用4个空格的缩进. 在文本编辑器中,需要设置把T ...
- Java JDK安装教程以及JDK多版本间快速切换配置
原本想自己写一篇,结果在网上发现一篇写的特别好的博文,大家可以去原网址围观浏览加点赞, 只是搬运工+迷弟. 原文地址:https://blog.csdn.net/qq_38916130/article ...
- Token 认证
Token 认证 From今日头条:https://www.toutiao.com/i6516654967204348430/?tt_from=weixin&utm_campaign=clie ...
- “希希敬敬对”团队--‘百度贴吧小爬虫’Alpha版本展示博客
希希敬敬对的 Alpha阶段测试报告 随笔链接地址 https://www.cnblogs.com/xiaoyoushang/p/10078826.html Alpha版本发布说明 随笔链接地址 ...
- IO流 -字符输入输出流,以及异常处理方法
字符输入流 java.io.Reader: 字符输入流的顶层抽象父类 共性的成员方法: int read() 读取单个字符,并返回. int read(char[] cbuf) 将字符读入数组. ab ...