在PHP中将字符转为大写的函数是“strtoupper()”,该函数的作用是将字符串转化为大写,语法为“strtoupper(string $string)”,返回值为转换后的大写字符串。幼儿园设计
推荐视频教程:《PHP教程》
示例代码
1
2
3
4
5
|
<?php
$str = "Mary Had A Little Lamb and She LOVED It So" ;
$str = strtoupper ( $str );
echo $str ;
?>
|
使用示例
1
2
3
4
5
6
7
8
9
10
11
|
<?php
define( "LATIN1_UC_CHARS" , "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ" );
define( "LATIN1_LC_CHARS" , "àáâãäåæçèéêëìíîïðñòóôõöøùúûüý" );
function uc_latin1 ( $str ) {
$str = strtoupper ( strtr ( $str , LATIN1_LC_CHARS, LATIN1_UC_CHARS));
return strtr ( $str , array ( "ß" => "SS" ));
}
?>
|
1
2
3
4
5
6
7
8
9
10
|
<?php
function strtoupper_utf8( $string ){
$string =utf8_decode( $string );
$string = strtoupper ( $string );
$string =utf8_encode( $string );
return $string ;
}
?>
|