PHP_FUNCTION(ucwords)
{
zend_string *str;
char *delims = " \t\r\n\f\v";
register char *r, *r_end;
size_t delims_len = ;
char mask[]; ZEND_PARSE_PARAMETERS_START(, )
Z_PARAM_STR(str)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(delims, delims_len)
ZEND_PARSE_PARAMETERS_END(); if (!ZSTR_LEN(str)) {
RETURN_EMPTY_STRING();
} php_charmask((unsigned char *)delims, delims_len, mask); // 初始化mask数组,并对上述6个字符执行类似这样的操作:char c='\t';mask[c]=1; ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str)); //初始化函数返回值return_value
r = Z_STRVAL_P(return_value); //新字符串首地址 *r = toupper((unsigned char) *r); //将新字符串首字符大写转换
for (r_end = r + Z_STRLEN_P(return_value) - ; r < r_end; ) {//一次遍历每个字符
if (mask[(unsigned char)*r++]) { // 字符如果是上述6个之一,则该字符后面的字符进行大写转换
*r = toupper((unsigned char) *r);
}
}
//结束之后,将返回return_value
}

php内置函数分析之ucwords()的更多相关文章

  1. map内置函数分析所得到的思路

    map:会根据提供的函数对指定序列做映射. map(func, *iterables) --> map object Make an iterator that computes the fun ...

  2. php内置函数分析之array_diff_assoc()

    static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_type) /* {{{ */ { uint ...

  3. php内置函数分析之array_combine()

    PHP_FUNCTION(array_combine) { HashTable *values, *keys; uint32_t pos_values = ; zval *entry_keys, *e ...

  4. php内置函数分析之strtoupper()、strtolower()

    strtoupper(): PHP_FUNCTION(strtoupper) { zend_string *str; ZEND_PARSE_PARAMETERS_START(, ) Z_PARAM_S ...

  5. php内置函数分析之ucfirst()、lcfirst()

    ucfirst($str) 将 str 的首字符(如果首字符是字母)转换为大写字母,并返回这个字符串. 源码位于 ext/standard/string.c /* {{{ php_ucfirst Up ...

  6. php内置函数分析之trim()

    官方手册中: 类似函数还有两个:ltrim() 和 rtrim().分别处理字符串的左侧.右侧. trim()的具体实现位于:ext/standard/string.c /* {{{ proto st ...

  7. php内置函数分析之str_pad()

    PHP_FUNCTION(str_pad) { /* Input arguments */ zend_string *input; /* Input string 输入字符串*/ zend_long ...

  8. php内置函数分析之array_fill_keys()

    PHP_FUNCTION(array_fill_keys) { zval *keys, *val, *entry; if (zend_parse_parameters(ZEND_NUM_ARGS(), ...

  9. php内置函数分析range()

    PHP_FUNCTION(range) { zval *zlow, *zhigh, *zstep = NULL, tmp; , is_step_double = ; double step = 1.0 ...

随机推荐

  1. characteristics of competent communicators

    https://www.universalclass.com/articles/business/communication-studies/be-a-competent-communicator.h ...

  2. Qualcomm 8X camera过程解析【转】

    本文转载自:http://blog.csdn.net/gabbzang/article/details/19906687 http://www.01yun.com/mobile_development ...

  3. P3928奶酪

    传送 今天早晨,神志不清的我决定拿头过这道题 终于在wa了6次之后过了 emm  明明都是一些细节自己却注意不到啊啊啊不能再颓了!!!!!!!!!!!! 好了回归正题 首先我们要开long long ...

  4. Openstack 通过 SQLAlchemy-ORM 访问数据库

    目录 目录 Demo SQLAlchemy 数据库的初始化 数据库的操作实现 数据库的操作请求 全部查询 单个查询 创建 更新 删除 Demo Github/JmilkFan/my-code-repe ...

  5. G2 基本使用 折线图 柱状图 饼图 基本配置

    G2的基本使用 1.浏览器引入  <!-- 引入在线资源 --> <script src="https://gw.alipayobjects.com/os/lib/antv ...

  6. PHP 距离我最近排序+二维数组按指定列排序

    思路: 1.获取我的位置,即:我的经纬度 2.各站点须有位置     即:排序对象有位置经纬度 3.查询要排序的站点列表 4.循环遍历计算  与我的距离 5.二维数组按 指定列(距离)排序 具体如下: ...

  7. Learn Python the hard way, ex41 来自Percal 25 号星星的哥顿人

    我承认,我偷懒了,少打了大量代码(剧情),英文太差,下次可以编个中文的试试 #!/urs/bin/python #coding:utf-8 from sys import exit from rand ...

  8. unity editor 折叠树

    https://blog.csdn.net/e295166319/article/details/52370575 需要两个类:树节点类和界面实现类 1:树节点类(TreeNode) using Un ...

  9. 应用安全 - 软件漏洞 - Jira漏洞汇总

    CVE-2019-8451 ssrf url = url + '/plugins/servlet/gadgets/makeRequest?url=' + host + '@www.baidu.com/ ...

  10. vue集成汉字转拼音或提取首字母

    需求:             有时我们为了节省用户的维护量,需要根据中文生成出相应的拼音和缩写 解决:            此方法是利用汉字和Unicode编码对应找到相应字母 一.编写汉字和编码 ...