Home » PHP

How to convert a string to uppercase in PHP?

In this PHP example, we are going to learn, how we can convert a string to uppercase? To convert string to uppercase, we use strtoupper() method which returns uppercase converted string.
Submitted by IncludeHelp, on October 17, 2017

PHP - strtoupper()

This method takes a string in any case as an argument and returns uppercase string.


	$str = 'hello friends';
	echo strtoupper($str) 



Other functions:

PHP - ucfirst ()

This function converts first letter in uppercase of the string.


echo ucfirst("hello friend");
//output: Hello friends

PHP - ucwords ()

This function converts each first character of all words in uppercase.


echo ucwords("how are you");
//Output: How Are You?

Complete code (HTML with PHP)

		<title> PHP code to get textbox value and print it in Uppercase </title>
		<form action="">
			<input type="text" id="str" type="text" name="str" maxlength="10" size="26">

			<input type="submit" name="submit" formmethod="POST">

				$str = strtoupper($_POST['str']);
				echo "convert to upper case";
				echo $str;	


PHP example to convert into uppercase

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.