1.strtolower(): 该函数将传入的字符串参数所有的字符都转换成小写,并以小写形式放回这个字符串.
 
<?php
$str = strtolower($str);
echo $str; // Prints mary had a little lamb and she loved it so
?>
 
2.strtoupper(): 该函数的作用同strtolower函数相反,是将传入的字符参数的字符全部转换成大写,并以大写的形式返回这个字符串.用法同strtolowe()一样.
 
<?php
$str = strtoupper($str);
echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
 
3.ucfirst(): 该函数的作用是将字符串的第一个字符改成大写,该函数返回首字符大写的字符串.用法同strtolowe()一样.
 
<?php
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!
 
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
 
 
<?php
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World!
 
$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>

相关文章:

  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2021-07-10
猜你喜欢
  • 2022-01-31
  • 2022-12-23
  • 2022-02-07
  • 2021-11-02
  • 2021-10-13
  • 2021-12-28
  • 2022-12-23
相关资源
相似解决方案