admin 发表于 2023-2-16 18:54:44

PHP Filter 函数

<div id="article_content" class="article_content clearfix">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-6e43165c0a.css">
                <div id="content_views" class="htmledit_views">
                  <h2>PHP Filter 简介</h2>
<p>PHP 过滤器用于对来自非安全来源的数据&#xff08;比如用户输入&#xff09;进行验证和过滤。</p>
<hr>
<h2>安装</h2>
<p>Filter 函数是 PHP 核心的组成部分。无需安装即可使用这些函数。</p>
<hr>
<h2>PHP Filter 函数</h2>
<p><strong>PHP</strong>&#xff1a;指示支持该函数的最早的 PHP 版本。</p>
<table><tbody><tr><th>函数</th><th>描述</th><th>PHP</th></tr><tr><td><ahref="https://www.runoob.com/php/func-filter-has-var.html">filter_has_var()</a></td><td>检查是否存在指定输入类型的变量。</td><td>5</td></tr><tr><td><ahref="https://www.runoob.com/php/func-filter-id.html">filter_id()</a></td><td>返回指定过滤器的 ID 号。</td><td>5</td></tr><tr><td><ahref="https://www.runoob.com/php/func-filter-input.html">filter_input()</a></td><td>从脚本外部获取输入&#xff0c;并进行过滤。</td><td>5</td></tr><tr><td><ahref="https://www.runoob.com/php/func-filter-input-array.html">filter_input_array()</a></td><td>从脚本外部获取多项输入&#xff0c;并进行过滤。</td><td>5</td></tr><tr><td><ahref="https://www.runoob.com/php/func-filter-list.html">filter_list()</a></td><td>返回包含所有得到支持的过滤器的一个数组。</td><td>5</td></tr><tr><td><ahref="https://www.runoob.com/php/func-filter-var-array.html">filter_var_array()</a></td><td>获取多个变量&#xff0c;并进行过滤。</td><td>5</td></tr><tr><td><ahref="https://www.runoob.com/php/func-filter-var.html">filter_var()</a></td><td>获取一个变量&#xff0c;并进行过滤。</td><td>5</td></tr></tbody></table>
<p></p>
<hr>
<h2>PHP 过滤器</h2>
<table><tbody><tr><th>ID 名称</th><th>描述</th></tr><tr><td><ahref="https://www.runoob.com/php/filter-callback.html">FILTER_CALLBACK</a></td><td>调用用户自定义函数来过滤数据。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-sanitize-string.html">FILTER_SANITIZE_STRING</a></td><td>去除标签&#xff0c;去除或编码特殊字符。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-sanitize-stripped.html">FILTER_SANITIZE_STRIPPED</a></td><td>&#34;string&#34; 过滤器的别名。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-sanitize-encoded.html">FILTER_SANITIZE_ENCODED</a></td><td>URL-encode 字符串&#xff0c;去除或编码特殊字符。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-sanitize-special-chars.html">FILTER_SANITIZE_SPECIAL_CHARS</a></td><td>HTML 转义字符 '&#34;<>& 以及 ASCII 值小于 32 的字符。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-sanitize-email.html">FILTER_SANITIZE_EMAIL</a></td><td>删除所有字符&#xff0c;除了字母、数字以及 !#$%&'*&#43;-/&#61;?^_&#96;{|}~&#64;.[]</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-sanitize-url.html">FILTER_SANITIZE_URL</a></td><td>删除所有字符&#xff0c;除了字母、数字以及 $-_.&#43;!*'(),{}|\^~[]&#96;<>#%&#34;;/?:&#64;&&#61;</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-sanitize-number-int.html">FILTER_SANITIZE_NUMBER_INT</a></td><td>删除所有字符&#xff0c;除了数字和 &#43;-</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-sanitize-number-float.html">FILTER_SANITIZE_NUMBER_FLOAT</a></td><td>删除所有字符&#xff0c;除了数字、&#43;- 以及 .,eE</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-sanitize-magic-quotes.html">FILTER_SANITIZE_MAGIC_QUOTES</a></td><td>应用 addslashes()。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-unsafe-raw.html">FILTER_UNSAFE_RAW</a></td><td>不进行任何过滤&#xff0c;去除或编码特殊字符。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-validate-int.html">FILTER_VALIDATE_INT</a></td><td>把值作为整数来验证。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-validate-boolean.html">FILTER_VALIDATE_BOOLEAN</a></td><td>把值作为布尔选项来验证。如果是 &#34;1&#34;、&#34;true&#34;、&#34;on&#34; 和 &#34;yes&#34;&#xff0c;则返回 TRUE。如果是 &#34;0&#34;、&#34;false&#34;、&#34;off&#34;、&#34;no&#34; 和 &#34;&#34;&#xff0c;则返回 FALSE。否则返回 NULL。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-validate-float.html">FILTER_VALIDATE_FLOAT</a></td><td>把值作为浮点数来验证。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-validate-regexp.html">FILTER_VALIDATE_REGEXP</a></td><td>根据 regexp&#xff08;一种兼容 Perl 的正则表达式&#xff09;来验证值。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-validate-url.html">FILTER_VALIDATE_URL</a></td><td>把值作为 URL 来验证。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-validate-email.html">FILTER_VALIDATE_EMAIL</a></td><td>把值作为 e-mail 地址来验证。</td></tr><tr><td><ahref="https://www.runoob.com/php/filter-validate-ip.html">FILTER_VALIDATE_IP</a></td><td>把值作为 IP 地址来验证&#xff0c;只限 IPv4 或 IPv6 或 不是来自私有或者保留的范围。</td></tr></tbody></table>
                </div>
      </div>
      <div id="treeSkill"></div>
页: [1]
查看完整版本: PHP Filter 函数