com doc/zh: Update filter-var.xml Close php/doc-zh#4: reference/filter/functions/filter-var.xml
| From: | Dai Jie | Date: | Sat, 16 Jan 2021 08:30:22 +0000 |
| Subject: | com doc/zh: Update filter-var.xml Close php/doc-zh#4: reference/filter/functions/filter-var.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-5906@lists.php.net to get a copy of this message | ||
Commit: 297f8b64b4eb9411721b40d1bfc3b1663486b390
Author: 蒋文健 <86849180@qq.com> Sat, 16 Jan 2021 16:12:53 +0800
Committer: daijie <daijie@php.net> Sat, 16 Jan 2021 16:30:22 +0800
Parents: 1f42039e9461f0cd373e7312af0b156c612ff276
Branches: master
Link: http://git.php.net/?p=doc/zh.git;a=commitdiff;h=297f8b64b4eb9411721b40d1bfc3b1663486b390
Log:
Update filter-var.xml
Close php/doc-zh#4
Bugs:
https://bugs.php.net/4
Changed paths:
M reference/filter/functions/filter-var.xml
Diff:
diff --git a/reference/filter/functions/filter-var.xml b/reference/filter/functions/filter-var.xml
index 5b0627cc..5f243476 100644
--- a/reference/filter/functions/filter-var.xml
+++ b/reference/filter/functions/filter-var.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: e5f52bed940cf04f52aac9d5bdd4ce97a2dc4f42 Maintainer: Status: ready -->
+<!-- EN-Revision: 6e4ac10da6c9456f413316677a29d5296bdc5fb4 Maintainer: Status: ready -->
<!-- Generated by xml_proto.php v2.4. Found in /scripts directory of phpdoc. -->
<refentry xml:id="function.filter-var" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
@@ -11,9 +11,9 @@
&reftitle.description;
<methodsynopsis>
<type>mixed</type><methodname>filter_var</methodname>
-
<methodparam><type>mixed</type><parameter>variable</parameter></methodparam>
- <methodparam
choice="opt"><type>int</type><parameter>filter</parameter><initializer>FILTER_DEFAULT</initializer></methodparam>
- <methodparam
choice="opt"><type>mixed</type><parameter>options</parameter></methodparam>
+
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
+ <methodparam
choice="opt"><type>int</type><parameter>filter</parameter><initializer><constant>FILTER_DEFAULT</constant></initializer></methodparam>
+ <methodparam choice="opt"><type
class="union"><type>array</type><type>int</type></type><parameter>options</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
</refsect1>
@@ -22,11 +22,10 @@
<para>
<variablelist>
<varlistentry>
- <term><parameter>variable</parameter></term>
+ <term><parameter>value</parameter></term>
<listitem>
<para>
- 待过滤的变量。注意:标量的值在过滤前,会被<link
- linkend="language.types.string.casting">转换成字符串</link>。
+ 要过滤的内容。注意:标量值在过滤前,会被<link
linkend="language.types.string.casting">转换成字符串</link>。
</para>
</listitem>
</varlistentry>
@@ -35,36 +34,33 @@
<term><parameter>options</parameter></term>
<listitem>
<para>
-
一个选项的关联数组,或者按位区分的标示。如果过滤器接受选项,可以通过数组的
"flags" 位去提供这些标示。
- 对于回调型的过滤器,应该传入
<type>callable</type>。这个回调函数必须接受一个参数,即待过滤的值,并且
- 返回一个在过滤/净化后的值。
+
一个选项的关联数组,或者按位区分的标示。如果过滤器接受选项,可以通过数组的
"flags" 下标去提供这些标示。
+ 对于回调型的过滤器,应该传入 <type>callable</type>。
+
这个回调函数必须接受一个参数(即待过滤的值),并且返回一个在过滤/净化后的值。
</para>
<para>
<programlisting role="php">
<![CDATA[
<?php
-// for filters that accept options, use this format
+// 对于接受选项的过滤器,请使用此格式
$options = array(
'options' => array(
- 'default' => 3, // value to return if the filter fails
- // other options here
+ 'default' => 3, // 过滤器失败时返回的值
+ // 可以继续写过滤器接收其它选项
'min_range' => 0
),
'flags' => FILTER_FLAG_ALLOW_OCTAL,
);
$var = filter_var('0755', FILTER_VALIDATE_INT, $options);
-
-// for filter that only accept flags, you can pass them directly
+// 对于仅接受标志的过滤器,您可以直接将其传递
$var = filter_var('oops', FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
-
-// for filter that only accept flags, you can also pass as an array
+// 对于仅接受标志的过滤器,您还可以将其作为数组传递
$var = filter_var('oops', FILTER_VALIDATE_BOOLEAN,
array('flags' => FILTER_NULL_ON_FAILURE));
-
-// callback validate filter
+// 回调类型过滤器
function foo($value)
{
- // Expected format: Surname, GivenNames
+ // 预期值: Surname, GivenNames
if (strpos($value, ", ") === false) return false;
list($surname, $givennames) = explode(", ", $value, 2);
$empty = (empty($surname) || empty($givennames));
@@ -88,7 +84,7 @@ $var = filter_var('Doe, Jane Sue', FILTER_CALLBACK,
array('options' => 'foo'));
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
- Returns the filtered data, or &false; if the filter fails.
+ 返回过滤后的数据,如果过滤失败则返回 &false; 。
</para>
</refsect1>
@@ -96,7 +92,7 @@ $var = filter_var('Doe, Jane Sue', FILTER_CALLBACK,
array('options' => 'foo'));
&reftitle.examples;
<para>
<example>
- <title>一个 <function>filter_var</function> 的例子</title>
+ <title>一个 <function>filter_var</function> 的示例</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -123,13 +119,12 @@ bool(false)
<member><function>filter_var_array</function></member>
<member><function>filter_input</function></member>
<member><function>filter_input_array</function></member>
- <member><xref linkend="filter.filters" /></member>
+ <member><xref linkend="filter.filters"/></member>
</simplelist>
</para>
</refsect1>
</refentry>
-
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml