Web Development Blog

Convert String to Lowercase or Uppercase Tool (+ PHP code)

 This is very basic tool that will convert string to lower case.

 

 

Basically, all you need to know to write this tool, it 2 functions in PHP: string strtolower ( string $str ) and string strtoupper ( string $string )

Here is complete code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Convert String to Lowercase Tool </title>
<link href="/inc/styles.css" rel="stylesheet" type="text/css" />
</head>
<?
$txtToConv
=(!empty($_REQUEST["txtToConv"]))?addslashes($_REQUEST["txtToConv"]):'';
if(!empty(
$_REQUEST["convertTo"]) && $_REQUEST["convertTo"]=="Uppercase")
{
    
$output=stripslashes(
strtoupper($txtToConv));
}
else
{
    
$output=stripslashes(
strtolower($txtToConv));
}
?>
<body class="arial_12_dark_blue_bold" style="padding:5px;">
<form method="post">
Text to convert:<br />
<textarea class="contactField" name="txtToConv" id="txtToConv" style="width:550px; height:100px;"> <?=stripslashes($txtToConv)?></textarea><br /><br />
Convert to: <select class="contactField" style="width:100px; height:26px;" name="convertTo">
<option value="Lowercase">Lowercase</option>
<option value="Uppercase">Uppercase</option>
</select>
<input type="submit" name="Convert" value="Convert" />
Result:<br />
<textarea class="contactField" style="width:550px; height:100px;"><?=$output?></textarea>
</form>
</body>
</html>

Associated tags:  PHP, Strtolower, String, Lowercase, Tool

Comments:

Anh Tuans wrote on December 19, 2012 at 00:02
Not work with unicode characters like Ư, Ă, Ô. But this simple and cool tutorial. Thank you

Add Comment:

CAPTCHA