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) :-
Screenshot1 |
<?php $string = 'I Could Be Any Case.'; $string_lower = strtolower($string); echo $string_lower; ?>
Output (Screenshot2):-
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):-
Screenshot3 |
<?php $string = 'I Could Be Any Case.'; $string_lower = strtolower($string); $string_upper = strtoupper($string); echo $string_upper; ?>
Output (Screenshot4):-
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):-
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):-
Screenshot6 |
Screenshot7 |
Screenshot8 |
No comments:
Post a Comment
Thanks For Comment Will get you Soon..