• Register now to get access to thousands of Tutorials, Leaked content, Hot NSFW and much more. Join us as we build and grow the community.

Advertise Here

Advertise Here

Advertise Here

PHP - Simple String Conversion

fcfvff

Slice-of-Life Aficionado
F Rep
0
0
0
Rep
0
F Vouches
0
0
0
Vouches
0
Posts
134
Likes
149
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
In this tutorial we will create a Simple String Conversion using PHP. This code can be use in converting some string easily and automated. PHP is a server-side scripting language designed primarily for web development. Using PHP, you can let your user directly interact with the script and easily to learned its syntax. It is mostly used by a newly coders for its user friendly environment. So Let's do the coding.

Getting started

First you have to download & install XAMPP or any local server that run PHP scripts. In my case I used XAMPP as my local server, here's the link for XAMPP server https://www.apachefriends.org/index.html.

The Main Function

This code contains the main function of the application, This code will automatically convert your string to lowercase or uppercase depend on the word itsetl.To create this just write these block of code in the text editor, then name this file as convert.php
  1. <?php
  2. if

    (

    ISSET

    (

    $_GET

    [

    'word'

    ]

    )

    &&

    !

    empty

    (

    $_GET

    [

    'word'

    ]

    )

    )

    {
  3. if

    (

    ctype_lower

    (

    $_GET

    [

    'word'

    ]

    )

    )

    {
  4. $word

    =

    $_GET

    [

    'word'

    ]

    ;
  5. $upper_word

    =

    strtoupper

    (

    $word

    )

    ;
  6. echo

    "<h2 class='text-danger'>"

    .

    $upper_word

    .

    "</h2>"

    ;
  7. }

    else

    if

    (

    ctype_upper

    (

    $_GET

    [

    'word'

    ]

    )

    )

    {
  8. $word

    =

    $_GET

    [

    'word'

    ]

    ;
  9. $lower_word

    =

    strtolower

    (

    $word

    )

    ;
  10. echo

    "<h2 class='text-danger'>"

    .

    $lower_word

    .

    "</h2>"

    ;
  11. }
  12. }
  13. ?>

The Main Interface

This is the interface that display the output of the conversion,to make this just write these codes inside your text file, Then save it as index.php
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1"/>
  5. <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
  6. </head>
  7. <body>
  8. <nav class="navbar navbar-default">
  9. <div class=container-fluid>
  10. <a class="navbar-brand" href="https://sourcecodster.com">Sourcecodester</a>
  11. </div>
  12. </nav>
  13. <div class="col-md-3"></div>
  14. <div class="col-md-6 well">
  15. <h3 class="text-primary">PHP - Simple String Conversion</h3>
  16. <hr style="border-top:1px dotted #000;"/>
  17. <form method="GET" action="">
  18. <div class="col-md-3"></div>
  19. <div class="form-inline col-md-8">
  20. <h3>Type a Word</h3>
  21. <label class="text-success">*Word must be all UPPER or lower to make this work</label>
  22. <br /><br />
  23. <input type="text" name="word" class="form-control"/>
  24. <button type="submit" class="btn btn-primary">Convert</button>
  25. <br /><br />
  26. <?php

    include

    'convert.php'

    ?>
  27. </div>
  28. </form>
  29. </div>
  30. </body>
  31. </html>

There you have it we successfully created a Simple String Conversion 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. Enjoy Coding!!


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

452,500

350,639

350,649

Top