-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathsscanf.xml
174 lines (167 loc) · 5.28 KB
/
sscanf.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 5e6e91b7dc20a1872c553d49ebb2144d22396177 Maintainer: jpberdejo Status: ready -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.sscanf" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>sscanf</refname>
<refpurpose>Interpreta un string de entrada de acuerdo con un formato</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>mixed</type><methodname>sscanf</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
<methodparam choice="opt"><type>mixed</type><parameter role="reference">...</parameter></methodparam>
</methodsynopsis>
<para>
La función <function>sscanf</function> es la entrada análoga de
<function>printf</function>. <function>sscanf</function> lee
del string <parameter>str</parameter> y lo interpreta
de acuerdo con el <parameter>format</parameter> especificado, el cual está
descrito en la documentación para <function>sprintf</function>.
</para>
<para>
Cualquier espacio en blanco en el string de formato coincide con cualquier espacio en blanco en string
de entrada. Esto significa que incluso un tabulador \t en el string de formato puede coincidir con un
caracter simple de espacio en el string de entrada.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>str</parameter></term>
<listitem>
<para>
El <type>string</type> de entrada para ser interpretado.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>format</parameter></term>
<listitem>
<para>
El formato interpretado <parameter>str</parameter>, el cual está
descrito en la documentación para <function>sprintf</function> con
las siguientes diferencia:
<simplelist>
<member>
La función no es consciente de la configuración regional.
</member>
<member>
<literal>F</literal>, <literal>g</literal>, <literal>G</literal> y
<literal>b</literal> no están soportados.
</member>
<member>
<literal>D</literal> representa número decimal.
</member>
<member>
<literal>i</literal> representa integer con detección de base.
</member>
<member>
<literal>n</literal> representa el número de caracteres procesados hasta el momento.
</member>
</simplelist>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>...</parameter></term>
<listitem>
<para>
Opcionalmente variables pasadas por referencia que contendrán los valores interpretados.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Si sólo se pasan dos parámetros a esta función, los valores interpretados
se devolverán como una matriz. De lo contrario, si se pasan parámetros opcionales,
la función devolverá el número de valores asignados. Los parámetros
opcionales se deben pasar por referencia.
</para>
<para>
Si hay más substrings esperados en el <parameter>format</parameter>
que los que hay disponibles en <parameter>str</parameter>,
será devuelto <literal>-1</literal>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Ejemplo de <function>sscanf</function></title>
<programlisting role="php">
<![CDATA[
<?php
// obtener el número serial
list($serial) = sscanf("SN/2350001", "SN/%d");
// y la fecha de manufactura
$mandate = "January 01 2000";
list($month, $day, $year) = sscanf($mandate, "%s %d %d");
echo "Item $serial was manufactured on: $year-" . substr($month, 0, 3) . "-$day\n";
?>
]]>
</programlisting>
</example>
</para>
<para>
Si se pasan parámetros opcionales, la función devolverá el
número de valores asignados.
</para>
<para>
<example>
<title><function>sscanf</function> - using optional parameters</title>
<programlisting role="php">
<![CDATA[
<?php
// obtener la información del autor y generar entrada DocBook
$auth = "24\tLewis Carroll";
$n = sscanf($auth, "%d\t%s %s", $id, $first, $last);
echo "<author id='$id'>
<firstname>$first</firstname>
<surname>$last</surname>
</author>\n";
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>fscanf</function></member>
<member><function>printf</function></member>
<member><function>sprintf</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- 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
-->