How to remove HTML tags from the PHP string or get a string from the HTML content?; In this post, you will learn how to sanitize your PHP string from the HTML tag or HTML content layout.
The PHP function filter_var() will remove your HTML all tags and make plain PHP strings from the HTML content. Having read this tutorial you will learn how to remove HTML all tags from the PHP string.
To remove all HTML tags from PHP strain we will pass wo argument. The first argument HTML content and second argument we will pass type to check the string using this function.
<?php
$str = "<h1>Hello World!</h1>";
$newstr = filter_var($str, FILTER_SANITIZE_STRING);
echo $newstr;
// OUTPUT
// Hello World!
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- Firebase Notification Send Example
- could not encode content to iso-8859-1
- How To Check Valid Integer Values Using PHP Function Example
- Error : Trying To Get Property Of ID Non-Object All Possible Solution Guideline In Laravel - PHP
- How To Add Google reCAPTCHA v3 In HTML Form Based PHP/Laravel Website
- Generate Captcha Code Image With Form Validation - PHP
- Adding Watermark On Image In PHP Example
- Slug PHP Function Example - slugify($string)
- How To Get Current Request Method Post Patch Get In Laravel - PHP
- How To Add Google reCAPTCHA v2 In HTML Form Based PHP/Laravel Website