input data should be validated using functions such as strip_tags and utf8_decode. Dynamics content should be HTML encoded using htmlspecialchars.
用户输入的数据用strip_tags和utf8_decode处理,为什么读取数据还要用htmlspecialchars处理?
前面已经用strip_tags把标签去掉了
回复讨论(解决方案)
if($text != strip_tags($text)) {
//含有 HTML 内容,怎么处理由你决定
}
utf8_decode 对中文无效,只会越搞越乱
Dynamics content should be HTML encoded using htmlspecialchars
动态内容可以用 htmlspecialchars 做 HTML 编码
if($text != strip_tags($text)) {
//含有 HTML 内容,怎么处理由你决定
}
utf8_decode 对中文无效,只会越搞越乱
Dynamics content should be HTML encoded using htmlspecialchars
动态内容可以用 htmlspecialchars 做 HTML 编码
utf8_encode() 函数把 ISO-8859-1 字符串编码为 UTF-8。
utf8_encode() 函数有什么用? 在什么情况下用到?
ISO-8859-1 是单字节字符集
其别名为 latin1,这个 latin1 你应该是知道的(MySQL的默认字符集)
latin1 又称欧洲标准字符集
if($text != strip_tags($text)) {
//含有 HTML 内容,怎么处理由你决定
}
utf8_decode 对中文无效,只会越搞越乱
Dynamics content should be HTML encoded using htmlspecialchars
动态内容可以用 htmlspecialchars 做 HTML 编码
那对于输入的数据,只用htmlspecialchars就可以了?
保存到数据库前: $input_data = htmlspecialchars($input_data);
从数据库读取(不用处理) $input_data
为什么呢?那么绝对?!
如果传入的是在线编辑器的数据,你也 htmlspecialchars ?
况且 htmlspecialchars 并不处理 ' (单引号),而数据库中是一定要转义的
为什么呢?那么绝对?!
如果传入的是在线编辑器的数据,你也 htmlspecialchars ?
况且 htmlspecialchars 并不处理 ' (单引号),而数据库中是一定要转义的
我现在有点乱,
对于表单保存进数据库前,需要对输入的数据进行什么处理,
从数据库读取现在到页面时,要对读取的数据进行什么处理
入库时转义特殊字符
出库后根据需要做相应处理

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov


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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

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

Dreamweaver CS6
Visual web development tools
