PHP - Remove HTML Tag from String
Submitted by razormist on Thursday, August 23, 2018 - 20:31.
In this tutorial we will create a Remove HTML Tag from String using PHP. 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...
There you have it we successfully created Remove HTML Tag from String 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!
Before we get 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. Lastly, 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 forms simply copy and write it into you 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://sourcecodester.com">Sourcecodester</a>
- </div>
- </nav>
- <div class="col-md-3"></div>
- <div class="col-md-6 well">
- <h3 class="text-primary">PHP - Remove HTML Tag from String</h3>
- <hr style="border=top:1px dotted #ccc;"/>
- <div class="col-md-3"></div>
- <div class="col-md-6">
- <?php include 'remove_html.php'?>
- </div>
- </div>
- </body>
- </html>
Creating the Main Function
This code contains the main function of the application. This code can remove the html tags inside the html variable.To do this just copy and write the code inside the text editor, then save it as remove_html.php.- <?php
- $data = "<h2><strong>Lorem ipsum</strong></h2>";
- $data .= "<br />";
- $data .= "<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.</p>";
- echo $html;
- ?>
- <br /><br />
- <form method="POST" action="">
- <center><button class="btn btn-warning" name="remove"><span class="glyphicon glyphicon-remove"></span> Remove Tags</button></center>
- </form>
- <h3>Result</h3>
- <?php
- echo $remove;
- }
- ?>
Add new comment
- 71 views