Table of Contents
Tutorial: Dynamically Change Font Size Using PHP Source Code
In this tutorial, we will create a Dynamically Change Font Size using PHP. This code can change the font size of a text when a user submits a form. The system uses PHP GET method to send and receive the request to change the given text size. This is a user-friendly kind of program feel free to modify it.
We will be using PHP as a scripting language and interpreter that is primarily on any web server, including xamp, wamp, etc. This is to any popular websites, and it has a modern technology that can easily be used by the next generation.
Getting Started:
First, you have to download & install XAMPP or any local server that run PHP scripts. Here’s the link for XAMPP server https://www.apachefriends.org/index.html.
And, this is the link for the bootstrap that I used for the layout design https://getbootstrap.com/.
Creating The Interface
This is where we will create a simple form for our application. To create the copy of the way and write it into your text editor, then save it as index.php.In this tutorial, we will create a Currency Converter App using PHP. This code will convert the current money to a different country when the user submits the form value. The system uses a PHP POST to call a specific method that sends the cost and save it to the currency options by calculating with unique formulas. This is a user-friendly kind of program feel free to modify it.
Getting Started:
First, you have to download & install XAMPP or any local server that run PHP scripts. Here’s the link for XAMPP server https://www.apachefriends.org/index.html.
And, this is the link for the bootstrap that I used for the layout design https://getbootstrap.com/.
Creating The Interface
This is where we will create a simple form for our application. To create the copy of the way and write it into your text editor, then save it as index.php.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> </head> <body> <nav class="navbar navbar-default"> <div class=container-fluid> <a class="navbar-brand" href="https://sourcecodster.com">Sourcecodester</a> </div> </nav> <div class="col-md-3"></div> <div class="col-md-6 well"> <h3 class="text-primary">Dynamically Change Font Size Using PHP Source Code</h3> <hr style="border-top:1px dotted #000;"/> <div class="col-md-5"> <form method="GET" action=""> <div class="form-group"> <h3>Type a String</h3> <h6 class='text-danger'>Word must be in UPPER or LOWER CASE</h6> <input type="text" name="word" class="form-control"/> </div> <button type="submit" class="btn btn-primary">Convert</button> <br /><br /> <?php include'change.php'?> </form> </div> </body> </html>
Creating the Main Function
This code contains the main function of the application. This code change the font size when the button is clicked. To make this just copy and write these block of codes below inside the text editor, then save it as change.php.
<?php if(ISSET($_GET['word']) && !empty($_GET['word'])){ if(ctype_lower($_GET['word'])){ $word=$_GET['word']; $upper_word=strtoupper($word); echo "<h2 class='text-info'>".$upper_word."</h2>"; }else if(ctype_upper($_GET['word'])){ $word=$_GET['word']; $lower_word=strtolower($word); echo "<h2 class='text-info'>".$lower_word."</h2>"; } } ?>
Output:
There you have it we successfully created Dynamically Change Font Size using PHP. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Happy Coding!
Download Here