Wednesday 12 March 2014

String Function Upper and Lower Case Conversion in php


upper case lower case
String Function Upper and Lower Case Conversion in php programming languages. We will also talk about where we will use in real life example let see some example of string functions.

Code For String Function Lower Case (Screenshot1) :-

string function upper lower case conversion php
Screenshot1


<?php



$string = 'I Could Be Any Case.';

$string_lower = strtolower($string);



echo $string_lower;



?>

Output (Screenshot2):-

String functions php
Screenshot2
I had simple static string like just say I could be any case. This string could be user supply data or static string like just using in example. Now what happen if i create this string completely in lower case. strtolower functions creating new variable $string_lower is equal to strtolower function and with parameters the string which we want to convert $string. Then we output $string_lower and as u can see output starting I is covert into lower case i and also all other starting other words.

Code for string function Upper case (Screenshot3):-

strtolower function
Screenshot3


<?php



$string = 'I Could Be Any Case.';

$string_lower = strtolower($string);

$string_upper = strtoupper($string);



echo $string_upper;



?>

Output (Screenshot4):-

strtoupper function
Screenshot4
In this example we are converting whole string to upper case. as you see output. So, Its so simple to upper case to lower case and from lower case to upper.
Now Why we want to use this functions inside php? Let see example for this.

Code for string function (Screenshot5):-

strtolower function to strtoupper function conversion
Screenshot5



<?php



if (isset($_GET['user_name'])&&(!empty($_GET['user_name'])) {

$user_name = $_GET['user_name'];

$user_name_lc = strtolower($user_name);



if ($user_name_lc=='alex')  {

echo 'You are the best, '. $user_name;

}

}

?>



<form action="index.php" method="GET">

Name: <input type="text" name="user_name"><br />

<input type="Submit" value="Submit">

</form>

output (Screenshot6,Screenshot7, Screenshot8):-

String Function Upper and Lower Case Conversion in php
Screenshot6
String Function Upper and Lower Case Conversion in php
Screenshot7
String Function Upper and Lower Case Conversion in php
Screenshot8



No comments:

Post a Comment

Thanks For Comment Will get you Soon..

About Me

Welcome to Extra Tutorials! My name is Mohammed and I am the 22 year writer, website developer, and photographer behind the blog. Thanks for visiting! Tutorials Jackpot… In addition to Developer, I love to develop websites and I love to write. Starting a php Blog was inevitable for me. What began as a simple way to share all of my Tutorials with friends and family has developed into my Part time job.

Mohammed Padela

WHAT IS PHP PROGRAMMING

WHAT IS PHP PROGRAMMING
WHAT IS PHP PROGRAMMING

Follow Us

Popular Posts

Designed ByBlogger Templates