The solution to thinkphp not filtering html tags: 1. Open the corresponding tp file; 2. Use the "strip_tags(htmlspecialchars_decode($data['post']['post_content'])); method to The converted entity can be reversed.
The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.
What should I do if thinkphp does not filter html tags?
TP5 The solution to using strip_tags to filter html tags does not work
The solution to using strip_tags to filter html tags in ThinkPHP5 does not work
During the article saving process, you need to obtain the text in the html content edited by the Uediter editor on the front end. The basic idea is to use PHP's own function strip_tags() to directly filter
So edit it directly as follows:
$data = $this->request->param(); $data['post']['content'] = strip_tags($data['post']['post_content']); echo $data['post']['post_content']; echo $data['post']['content'];
The output content is as follows, the strip_tags() function does not play a role:
<p>RWERWERWhgj<strong>ghhfhgn</strong>bfghgh</p> <p>RWERWERWhgj<strong>ghhfhgn</strong>bfghgh</p>
Looking at the TP5 manual-input variable chapter-variable filtering we can find out By default, TP5 uses htmlspecialchars to convert the string passed from the front end into HTML entities. Therefore, my solution is to reverse the converted entities. This can be achieved by using the htmlspecialchars_decode() function:
$data = $this->request->param(); $data['post']['content'] = strip_tags(htmlspecialchars_decode($data['post']['post_content'])); echo $data['post']['post_content']; echo $data['post']['content'];
The output is as follows, the conversion is successful:
<p>RWERWERWhgj<strong>ghhfhgn</strong>bfghgh</p> RWERWERWhgjghhfhgnbfghgh
Recommended learning: "thinkPHP Video Tutorial"
The above is the detailed content of What to do if thinkphp does not filter html tags. For more information, please follow other related articles on the PHP Chinese website!

The article discusses ThinkPHP's built-in testing framework, highlighting its key features like unit and integration testing, and how it enhances application reliability through early bug detection and improved code quality.

Article discusses using ThinkPHP for real-time stock market data feeds, focusing on setup, data accuracy, optimization, and security measures.

The article discusses key considerations for using ThinkPHP in serverless architectures, focusing on performance optimization, stateless design, and security. It highlights benefits like cost efficiency and scalability, but also addresses challenges

The article discusses implementing service discovery and load balancing in ThinkPHP microservices, focusing on setup, best practices, integration methods, and recommended tools.[159 characters]

ThinkPHP's IoC container offers advanced features like lazy loading, contextual binding, and method injection for efficient dependency management in PHP apps.Character count: 159

The article discusses using ThinkPHP to build real-time collaboration tools, focusing on setup, WebSocket integration, and security best practices.

ThinkPHP benefits SaaS apps with its lightweight design, MVC architecture, and extensibility. It enhances scalability, speeds development, and improves security through various features.

The article outlines building a distributed task queue system using ThinkPHP and RabbitMQ, focusing on installation, configuration, task management, and scalability. Key issues include ensuring high availability, avoiding common pitfalls like imprope


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment