belongs to collection: PHP String Programs
How to convert a string to uppercase in PHP?
This method takes a string in any case as an argument and returns uppercase string.
Example
<?php $str = 'hello friends'; echo strtoupper($str) ?>
Output
HELLO FRIENDS
Other functions:
This function converts first letter in uppercase of the string.
<?php echo ucfirst("hello friend"); //output: Hello friends ?>
This function converts each first character of all words in uppercase.
<?php echo ucwords("how are you"); //Output: How Are You? ?>
Complete code (HTML with PHP)
<html> <head> <title> PHP code to get textbox value and print it in Uppercase </title> </head> <body> <form action=""> <input type="text" id="str" type="text" name="str" maxlength="10" size="26"> <input type="submit" name="submit" formmethod="POST"> </form> <?php if(isset($_POST['submit'])) { $str = strtoupper($_POST['str']); echo "convert to upper case"; echo $str; } ?> </body> </html>
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
PHP - strtoupper()
This method takes a string in any case as an argument and returns uppercase string.
Example
Output
Other functions:
PHP - ucfirst ()
This function converts first letter in uppercase of the string.
Example
PHP - ucwords ()
This function converts each first character of all words in uppercase.
Example
Complete code (HTML with PHP)
Output
need an explanation for this answer? contact us directly to get an explanation for this answer