PHP英文字母大小写转换函数小结
每个单词的首字母转换为大写:ucwords()
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World!
$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>
第一个单词首字母变大写:ucfirst()
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
第一个单词首字母变小写:lcfirst()
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>
所有字母变大写:strtoupper()
所有字母变小写:strtolower()
相关文章
由php的call_user_func传reference引发的思考
由php的call_user_func传reference引发的思考,使用call_user_func传reference的朋友可以参考下。2010-07-07
PHP Beanstalkd消息队列的安装与使用方法实例详解
这篇文章主要介绍了PHP Beanstalkd消息队列的安装与使用方法,结合实例形式详细分析了PHP Beanstalkd消息队列的基本功能、原理、安装、使用方法及相关操作注意事项,需要的朋友可以参考下2020-02-02
PHP中将字符串转化为整数(int) intval() printf() 性能测试
早在Sql注入横行的前几年,字符串转化为整数就已经被列为每个web程序必备的操作了。web程序将get或post来的id、整数等值强制经过转化函数转化为整数,过滤掉危险字符,尽可能降低系统本身被Sql注入的可能性2012-03-03


最新评论