PHP- strtoupper()
该方法在任何情况下都将字符串作为参数,并返回大写字符串。
例<?php
$str = 'hello friends';
echo strtoupper($str)
?>
输出结果HELLO FRIENDS
其他功能:
PHP-ucfirst()
此函数将字符串的首字母转换为大写。
例<?php
echo ucfirst("hello friend");
//输出:你好朋友
?>
PHP-ucwords()
此函数将所有单词的每个首字符转换为大写。
例<?php
echo ucwords("how are you");
//输出:你好吗?
?>
完整的代码(HTML和PHP)
PHP code to get textbox value and print it in Uppercaseif(isset($_POST['submit']))
{
$str = strtoupper($_POST['str']);
echo "convert to upper case";
echo $str;
}
?>
输出结果