这个 立法会一题( 函数是PHP中的一个内置函数,它以字符串作为参数,返回第一个小写字符的字符串,所有其他字符保持不变。
null
语法:
lcfirst($string)
参数: 该函数只接受一个参数 $string 这是强制性的。此参数表示其第一个字符将更改为小写的输入字符串。
返回值: 函数仅通过将传递的参数的第一个字符改为小写来返回相同的字符串 $string。
例如:
Input : "Geeks for geeks" Output : geeks for geeks Input : "chetna agarwal" Output : chetna agarwal
下面的程序演示了PHP中的lcfirst()函数:
项目1:
<?php // PHP program to demonstrates the // use of lcfirst() function $str = "Geeks for geeks" ; // converts the first character to // lower case and prints the string echo (lcfirst( $str )); ?> |
输出:
geeks for geeks
项目2: 下面的程序演示了当起始字符已经是小写时lcfirst()函数的用法。
<?php // PHP program that demonstrates the // use of lcfirst() function when // the first case is already in lowercase $str = "chetna agarwal" ; // already the first character is in lower case // so prints the same string only echo (lcfirst( $str )); ?> |
输出:
chetna agarwal
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END