1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-24 07:02:15 +01:00
Files
archived-doc-zh/reference/filter/book.xml
mowangjuanzi f9506babc1 Update filter (#957)
* Update constants_curl_setopt.xml

* Update filter

* Update filter-input.xml

* Update filter-input-array.xml

* Update

* Update

* Update ini.xml
2024-12-30 21:51:09 +08:00

59 lines
2.6 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 53054bf8decc8648cf2e90a493692a161e2371af Maintainer: mowangjuanzi Status: ready -->
<book xml:id="book.filter" xmlns="http://docbook.org/ns/docbook">
<?phpdoc extension-membership="bundled" ?>
<title>数据过滤器</title>
<titleabbrev>过滤器</titleabbrev>
<preface xml:id="intro.filter">
&reftitle.intro;
<simpara>
该扩展提供过滤器,用于验证或清理数据。当数据源包含像用户提供的输入数据等未知(或外部)数据时,这尤其有用。例如,这些数据可能来自 <acronym>HTML</acronym> 表单。
</simpara>
<simpara>
有两种主要的过滤类型:<emphasis>验证validation</emphasis><emphasis>清理sanitization</emphasis>
</simpara>
<simpara>
验证过滤器用于检查数据是否符合某些标准。这些过滤器通过 <constant>FILTER_VALIDATE_<replaceable>*</replaceable></constant>
常量区分。例如,<constant>FILTER_VALIDATE_EMAIL</constant> 过滤器可用于确定数据是否为有效的电子邮件地址。但是,它永远不会更改输入数据。
</simpara>
<simpara>
另一方面,清理将“清洁”数据,因此可能会通过添加或移除字符来更改输入数据。这些过滤器通过 <constant>FILTER_SANITIZE_<replaceable>*</replaceable></constant>
常量区分。例如,<constant>FILTER_SANITIZE_EMAIL</constant> 过滤器将删除电子邮件地址中不应该存在的字符。但是,清理后的数据不会验证是否是有效的电子邮件地址。
</simpara>
<simpara>
大多数过滤器都支持可选的 <emphasis>flag</emphasis>,这些 flag 可以调整过滤器的行为。这些标记通过 <constant>FILTER_FLAG_<replaceable>*</replaceable></constant>
常量区分。例如,将 <constant>FILTER_FLAG_PATH_REQUIRED</constant><constant>FILTER_VALIDATE_URL</constant> 验证过滤器一起使用,可以要求 URL
存在路径(例如 <literal>https://example.org/foo</literal> 中的 <literal>/foo</literal>)。
</simpara>
</preface>
&reference.filter.setup;
&reference.filter.constants;
&reference.filter.examples;
&reference.filter.reference;
</book>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->