MFB: finished ref.strings conversion to the new doc style

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@247736 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2007-12-07 01:18:14 +00:00
parent 5f71ee938f
commit 868fd0c40b
6 changed files with 805 additions and 487 deletions

View file

@ -1,110 +1,202 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.htmlspecialchars">
<refnamediv>
<refname>htmlspecialchars</refname>
<refpurpose>
Convert special characters to HTML entities
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>htmlspecialchars</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>quote_style</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>charset</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>double_encode</parameter></methodparam>
</methodsynopsis>
<para>
Certain characters have special significance in HTML, and should
be represented by HTML entities if they are to preserve their
meanings. This function returns a string with some of these
conversions made; the translations made are those most
useful for everyday web programming. If you require all HTML
character entities to be translated, use
<function>htmlentities</function> instead.
</para>
<simpara>
This function is useful in preventing user-supplied text from
containing HTML markup, such as in a message board or guest book
application. The optional second argument, <parameter>quote_style</parameter>, tells
the function what to do with single and double quote characters.
The default mode, <constant>ENT_COMPAT</constant>, is the backwards compatible mode
which only translates the double-quote character and leaves the
single-quote untranslated. If <constant>ENT_QUOTES</constant> is set, both single and
double quotes are translated and if <constant>ENT_NOQUOTES</constant> is set neither
single nor double quotes are translated.
</simpara>
<para>
The translations performed are:
<itemizedlist>
<listitem>
<simpara>
'&amp;' (ampersand) becomes '&amp;amp;'
</simpara>
</listitem>
<listitem>
<simpara>
'&quot;' (double quote) becomes '&amp;quot;' when <constant>ENT_NOQUOTES</constant>
is not set.
</simpara>
</listitem>
<listitem>
<simpara>
'&#039;' (single quote) becomes '&amp;#039;' only when
<constant>ENT_QUOTES</constant> is set.
</simpara>
</listitem>
<listitem>
<simpara>
'&lt;' (less than) becomes '&amp;lt;'
</simpara>
</listitem>
<listitem>
<simpara>
'&gt;' (greater than) becomes '&amp;gt;'
</simpara>
</listitem>
</itemizedlist>
<example>
<title><function>htmlspecialchars</function> example</title>
<programlisting role="php">
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.11 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.htmlspecialchars" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>htmlspecialchars</refname>
<refpurpose>Convert special characters to HTML entities</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>htmlspecialchars</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>quote_style</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>charset</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>double_encode</parameter></methodparam>
</methodsynopsis>
<para>
Certain characters have special significance in HTML, and should
be represented by HTML entities if they are to preserve their
meanings. This function returns a string with some of these
conversions made; the translations made are those most
useful for everyday web programming. If you require all HTML
character entities to be translated, use
<function>htmlentities</function> instead.
</para>
<simpara>
This function is useful in preventing user-supplied text from
containing HTML markup, such as in a message board or guest book
application.
</simpara>
<para>
The translations performed are:
<itemizedlist>
<listitem>
<simpara>
'&amp;' (ampersand) becomes '&amp;amp;'
</simpara>
</listitem>
<listitem>
<simpara>
'&quot;' (double quote) becomes '&amp;quot;' when <constant>ENT_NOQUOTES</constant>
is not set.
</simpara>
</listitem>
<listitem>
<simpara>
'&#039;' (single quote) becomes '&amp;#039;' only when
<constant>ENT_QUOTES</constant> is set.
</simpara>
</listitem>
<listitem>
<simpara>
'&lt;' (less than) becomes '&amp;lt;'
</simpara>
</listitem>
<listitem>
<simpara>
'&gt;' (greater than) becomes '&amp;gt;'
</simpara>
</listitem>
</itemizedlist>
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
The <type>string</type> being converted.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>quote_style</parameter></term>
<listitem>
<para>
The optional second argument, <parameter>quote_style</parameter>, tells
the function what to do with single and double quote characters.
The default mode, <constant>ENT_COMPAT</constant>, is the backwards compatible mode
which only translates the double-quote character and leaves the
single-quote untranslated. If <constant>ENT_QUOTES</constant> is set, both single and
double quotes are translated and if <constant>ENT_NOQUOTES</constant> is set neither
single nor double quotes are translated.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>charset</parameter></term>
<listitem>
<para>
Defines character set used in conversion.
The default character set is ISO-8859-1.
</para>
&reference.strings.charsets;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>double_encode</parameter></term>
<listitem>
<para>
When <parameter>double_encode</parameter> is turned off PHP will not
encode existing html entities, the default is to convert everything.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The converted <type>string</type>.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.2.3</entry>
<entry>
The <parameter>double_encode</parameter> parameter was added.
</entry>
</row>
<row>
<entry>4.1.0</entry>
<entry>
The <parameter>charset</parameter> parameter was added.
</entry>
</row>
<row>
<entry>4.0.3</entry>
<entry>
The <parameter>quote_style</parameter> parameter was added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>htmlspecialchars</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;
?>
]]>
</programlisting>
</example>
</para>
<para>
Note that this function does not translate anything beyond what
is listed above. For full entity translation, see
<function>htmlentities</function>. Support for the optional
second argument was added in PHP 3.0.17 and PHP 4.0.3.
</para>
<para>
The third argument <parameter>charset</parameter> defines character set
used in conversion. The default character set is ISO-8859-1. Support for
this third argument was added in PHP 4.1.0.
</para>
&reference.strings.charsets;
<para>
When <parameter>double_encode</parameter> is turned off PHP will not
encode existing html entities, the default is to convert everything.
This parameter was added in PHP 5.2.3.
</para>
<para>
See also <function>get_html_translation_table</function>,
<function>htmlspecialchars_decode</function>,
<function>strip_tags</function>,
<function>htmlentities</function>, and <function>nl2br</function>.
</para>
</refsect1>
</refentry>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
Note that this function does not translate anything beyond what
is listed above. For full entity translation, see
<function>htmlentities</function>.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>get_html_translation_table</function></member>
<member><function>htmlspecialchars_decode</function></member>
<member><function>strip_tags</function></member>
<member><function>htmlentities</function></member>
<member><function>nl2br</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:

View file

@ -1,124 +1,109 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.12 -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.levenshtein">
<refnamediv>
<refname>levenshtein</refname>
<refpurpose>
Calculate Levenshtein distance between two strings
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>levenshtein</methodname>
<methodparam><type>string</type><parameter>str1</parameter></methodparam>
<methodparam><type>string</type><parameter>str2</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>cost_ins</parameter></methodparam>
<methodparam><type>int</type><parameter>cost_rep</parameter></methodparam>
<methodparam><type>int</type><parameter>cost_del</parameter></methodparam>
</methodsynopsis>
<!-- Callback function not yet implemented, see bug #29552
<methodsynopsis>
<type>int</type><methodname>levenshtein</methodname>
<methodparam><type>string</type><parameter>str1</parameter></methodparam>
<methodparam><type>string</type><parameter>str2</parameter></methodparam>
<methodparam><type>callback</type><parameter>cost</parameter></methodparam>
</methodsynopsis>
-->
<para>
This function returns the Levenshtein-Distance between the
two argument strings or -1, if one of the argument strings
is longer than the limit of 255 characters.
</para>
<para>
The Levenshtein distance is defined as the minimal number of
characters you have to replace, insert or delete to transform
<parameter>str1</parameter> into <parameter>str2</parameter>.
The complexity of the algorithm is <literal>O(m*n)</literal>,
where <literal>n</literal> and <literal>m</literal> are the
length of <parameter>str1</parameter> and
<parameter>str2</parameter> (rather good when compared to
<function>similar_text</function>, which is O(max(n,m)**3),
but still expensive).
</para>
<para>
In its simplest form the function will take only the two
strings as parameter and will calculate just the number of
insert, replace and delete operations needed to transform
<parameter>str1</parameter> into <parameter>str2</parameter>.
</para>
<para>
A second variant will take three additional parameters that
define the cost of insert, replace and delete operations. This
is more general and adaptive than variant one, but not as
efficient.
</para>
<!-- Callback function not yet implemented, see bug #29552
<para>
The third variant (which is not implemented yet) will be the most
general and adaptive, but also the slowest alternative. It will
call a user-supplied function that will determine the cost for
every possible operation.
</para>
<para>
The user-supplied function will be called with the following
arguments:
<itemizedlist>
<listitem>
<simpara>
operation to apply: 'I', 'R' or 'D'
</simpara>
</listitem>
<listitem>
<simpara>
actual character in string 1
</simpara>
</listitem>
<listitem>
<simpara>
actual character in string 2
</simpara>
</listitem>
<listitem>
<simpara>
position in string 1
</simpara>
</listitem>
<listitem>
<simpara>
position in string 2
</simpara>
</listitem>
<listitem>
<simpara>
remaining characters in string 1
</simpara>
</listitem>
<listitem>
<simpara>
remaining characters in string 2
</simpara>
</listitem>
</itemizedlist>
The user-supplied function has to return a positive integer
describing the cost for this particular operation, but it may
decide to use only some of the supplied arguments.
</para>
<para>
The user-supplied function approach offers the possibility to
take into account the relevance of and/or difference between
certain symbols (characters) or even the context those symbols
appear in to determine the cost of insert, replace and delete
operations, but at the cost of losing all optimizations done
regarding cpu register utilization and cache misses that have
been worked into the other two variants.
</para>
-->
<para>
<example>
<title><function>levenshtein</function> example</title>
<programlisting role="php">
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.10 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.levenshtein" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>levenshtein</refname>
<refpurpose>Calculate Levenshtein distance between two strings</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>levenshtein</methodname>
<methodparam><type>string</type><parameter>str1</parameter></methodparam>
<methodparam><type>string</type><parameter>str2</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>cost_ins</parameter></methodparam>
<methodparam><type>int</type><parameter>cost_rep</parameter></methodparam>
<methodparam><type>int</type><parameter>cost_del</parameter></methodparam>
</methodsynopsis>
<para>
The Levenshtein distance is defined as the minimal number of
characters you have to replace, insert or delete to transform
<parameter>str1</parameter> into <parameter>str2</parameter>.
The complexity of the algorithm is <literal>O(m*n)</literal>,
where <literal>n</literal> and <literal>m</literal> are the
length of <parameter>str1</parameter> and
<parameter>str2</parameter> (rather good when compared to
<function>similar_text</function>, which is O(max(n,m)**3),
but still expensive).
</para>
<para>
In its simplest form the function will take only the two
strings as parameter and will calculate just the number of
insert, replace and delete operations needed to transform
<parameter>str1</parameter> into <parameter>str2</parameter>.
</para>
<para>
A second variant will take three additional parameters that
define the cost of insert, replace and delete operations. This
is more general and adaptive than variant one, but not as
efficient.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>str1</parameter></term>
<listitem>
<para>
One of the strings being evaluated for Levenshtein distance.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>str2</parameter></term>
<listitem>
<para>
One of the strings being evaluated for Levenshtein distance.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>cost_ins</parameter></term>
<listitem>
<para>
Defines the cost of insertion.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>cost_rep</parameter></term>
<listitem>
<para>
Defines the cost of replacement.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>cost_del</parameter></term>
<listitem>
<para>
Defines the cost of deletion.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
This function returns the Levenshtein-Distance between the
two argument strings or -1, if one of the argument strings
is longer than the limit of 255 characters.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>levenshtein</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// input misspelled word
@ -167,23 +152,30 @@ if ($shortest == 0) {
?>
]]>
</programlisting>
&example.outputs;
<screen>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Input word: carrrot
Did you mean: carrot?
]]>
</screen>
</example>
</para>
<para>
See also <function>soundex</function>,
<function>similar_text</function>, and
<function>metaphone</function>.
</para>
</refsect1>
</refentry>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>soundex</function></member>
<member><function>similar_text</function></member>
<member><function>metaphone</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:

View file

@ -1,58 +1,102 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/math.xml, last change in rev 1.2 -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.number-format">
<refnamediv>
<refname>number_format</refname>
<refpurpose>Format a number with grouped thousands</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>number_format</methodname>
<methodparam><type>float</type><parameter>number</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>decimals</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>dec_point</parameter></methodparam>
<methodparam><type>string</type><parameter>thousands_sep</parameter></methodparam>
</methodsynopsis>
<para>
<function>number_format</function> returns a formatted version of
<parameter>number</parameter>. This function accepts either one,
two or four parameters (not three):
</para>
<para>If only one parameter is given,
<parameter>number</parameter> will be formatted without decimals,
but with a comma (",") between every group of thousands.
</para>
<para>
If two parameters are given, <parameter>number</parameter> will
be formatted with <parameter>decimals</parameter> decimals with a
dot (".") in front, and a comma (",") between every group of
thousands.
</para>
<para>
If all four parameters are given, <parameter>number</parameter>
will be formatted with <parameter>decimals</parameter> decimals,
<parameter>dec_point</parameter> instead of a dot (".") before
the decimals and <parameter>thousands_sep</parameter> instead of
a comma (",") between every group of thousands.
</para>
<para>
Only the first character of <parameter>thousands_sep</parameter>
is used. For example, if you use <literal>bar</literal> as
<parameter>thousands_sep</parameter> on the number
<literal>1000</literal>, <function>number_format</function> will
return <literal>1b000</literal>.
</para>
<para>
<example>
<title><function>number_format</function> Example</title>
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.11 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.number-format" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>number_format</refname>
<refpurpose>Format a number with grouped thousands</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>number_format</methodname>
<methodparam><type>float</type><parameter>number</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>decimals</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>dec_point</parameter></methodparam>
<methodparam><type>string</type><parameter>thousands_sep</parameter></methodparam>
</methodsynopsis>
<para>
<function>number_format</function> returns a formatted version of
<parameter>number</parameter>. This function accepts either one,
two or four parameters (not three):
</para>
<para>If only one parameter is given,
<parameter>number</parameter> will be formatted without decimals,
but with a comma (",") between every group of thousands.
</para>
<para>
If two parameters are given, <parameter>number</parameter> will
be formatted with <parameter>decimals</parameter> decimals with a
dot (".") in front, and a comma (",") between every group of
thousands.
</para>
<para>
If all four parameters are given, <parameter>number</parameter>
will be formatted with <parameter>decimals</parameter> decimals,
<parameter>dec_point</parameter> instead of a dot (".") before
the decimals and <parameter>thousands_sep</parameter> instead of
a comma (",") between every group of thousands.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>number</parameter></term>
<listitem>
<para>
For instance, French notation usually use two decimals,
comma (',') as decimal separator, and space (' ') as
thousand separator. This is achieved with this line :
The number being formatted.
</para>
<programlisting role="php">
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>decimals</parameter></term>
<listitem>
<para>
Sets the number of decimal points.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>dec_point</parameter></term>
<listitem>
<para>
Sets the separator for the decimal point.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>thousands_sep</parameter></term>
<listitem>
<para>
Sets the thousands separator.
</para>
<para>
Only the first character of <parameter>thousands_sep</parameter>
is used. For example, if you use <literal>bar</literal> as
<parameter>thousands_sep</parameter> on the number
<literal>1000</literal>, <function>number_format</function> will
return <literal>1b000</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>number_format</function> Example</title>
<para>
For instance, French notation usually use two decimals,
comma (',') as decimal separator, and space (' ') as
thousand separator. This is achieved with this line :
</para>
<programlisting role="php">
<![CDATA[
<?php
@ -74,16 +118,24 @@ $english_format_number = number_format($number, 2, '.', '');
?>
]]>
</programlisting>
</example>
</para>
<para>
See also: <function>money_format</function>, <function>sprintf</function>,
<function>printf</function> and <function>sscanf</function>.
</para>
</refsect1>
</refentry>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>money_format</function></member>
<member><function>sprintf</function></member>
<member><function>printf</function></member>
<member><function>sscanf</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View file

@ -1,41 +1,83 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.16 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.33 -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.sscanf">
<refnamediv>
<refname>sscanf</refname>
<refpurpose>
Parses input from a string according to a format
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<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>
The function <function>sscanf</function> is the input analog of
<function>printf</function>. <function>sscanf</function> reads
from the string <parameter>str</parameter> and interprets it
according to the specified <parameter>format</parameter>, which is
described in the documentation for <function>sprintf</function>. If only
two parameters were passed to this function, the values parsed
will be returned as an array. Otherwise, if optional parameters are passed,
the function will return the number of assigned values. The optional
parameters must be passed by reference.
</para>
<para>
Any whitespace in the format string matches any whitespace in the input
string. This means that even a tab \t in the format string can match a
single space character in the input string.
</para>
<para>
<example>
<title><function>sscanf</function> Example</title>
<programlisting role="php">
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.17 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.sscanf" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>sscanf</refname>
<refpurpose>Parses input from a string according to a format</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>
The function <function>sscanf</function> is the input analog of
<function>printf</function>. <function>sscanf</function> reads
from the string <parameter>str</parameter> and interprets it
according to the specified <parameter>format</parameter>, which is
described in the documentation for <function>sprintf</function>.
</para>
<para>
Any whitespace in the format string matches any whitespace in the input
string. This means that even a tab \t in the format string can match a
single space character in the input string.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>str</parameter></term>
<listitem>
<para>
The input <type>string</type> being parsed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>format</parameter></term>
<listitem>
<para>
The interpreted format for <parameter>str</parameter>, which is
described in the documentation for <function>sprintf</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>...</parameter></term>
<listitem>
<para>
Optionally pass in variables by reference that will contain the parsed values.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
If only
two parameters were passed to this function, the values parsed
will be returned as an array. Otherwise, if optional parameters are passed,
the function will return the number of assigned values. The optional
parameters must be passed by reference.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>sscanf</function> Example</title>
<programlisting role="php">
<![CDATA[
<?php
// getting the serial number
@ -46,13 +88,17 @@ list($month, $day, $year) = sscanf($mandate, "%s %d %d");
echo "Item $serial was manufactured on: $year-" . substr($month, 0, 3) . "-$day\n";
?>
]]>
</programlisting>
</example>
If optional parameters are passed, the function will return the
number of assigned values.
<example>
<title><function>sscanf</function> - using optional parameters</title>
<programlisting role="php">
</programlisting>
</example>
</para>
<para>
If optional parameters are passed, the function will return the
number of assigned values.
</para>
<para>
<example>
<title><function>sscanf</function> - using optional parameters</title>
<programlisting role="php">
<![CDATA[
<?php
// get author info and generate DocBook entry
@ -64,15 +110,23 @@ echo "<author id='$id'>
</author>\n";
?>
]]>
</programlisting>
</example>
</para>
<para>
See also <function>fscanf</function>, <function>printf</function>,
and <function>sprintf</function>.
</para>
</refsect1>
</refentry>
</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:

View file

@ -1,28 +1,75 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strtok">
<refnamediv>
<refname>strtok</refname>
<refpurpose>Tokenize string</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>strtok</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>token</parameter></methodparam>
</methodsynopsis>
<para>
<function>strtok</function> splits a string (<parameter>str</parameter>)
into smaller strings (tokens), with each token being delimited by any
character from <parameter>token</parameter>.
That is, if you have a string like "This is an example string" you
could tokenize this string into its individual words by using the
space character as the token.
<example>
<title><function>strtok</function> example</title>
<programlisting role="php">
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.8 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strtok" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>strtok</refname>
<refpurpose>Tokenize string</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>strtok</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>token</parameter></methodparam>
</methodsynopsis>
<para>
<function>strtok</function> splits a string (<parameter>str</parameter>)
into smaller strings (tokens), with each token being delimited by any
character from <parameter>token</parameter>.
That is, if you have a string like "This is an example string" you
could tokenize this string into its individual words by using the
space character as the token.
</para>
<para>
Note that only the first call to strtok uses the string argument.
Every subsequent call to strtok only needs the token to use, as
it keeps track of where it is in the current string. To start
over, or to tokenize a new string you simply call strtok with the
string argument again to initialize it. Note that you may put
multiple tokens in the token parameter. The string will be
tokenized when any one of the characters in the argument are
found.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>str</parameter></term>
<listitem>
<para>
The <type>string</type> being split up into smaller strings (tokens).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>token</parameter></term>
<listitem>
<para>
The delimiter used when splitting up <parameter>str</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A <type>string</type> token.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>strtok</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$string = "This is\tan example\nstring";
@ -35,26 +82,18 @@ while ($tok !== false) {
}
?>
]]>
</programlisting>
</example>
</para>
<para>
Note that only the first call to strtok uses the string argument.
Every subsequent call to strtok only needs the token to use, as
it keeps track of where it is in the current string. To start
over, or to tokenize a new string you simply call strtok with the
string argument again to initialize it. Note that you may put
multiple tokens in the token parameter. The string will be
tokenized when any one of the characters in the argument are
found.
</para>
<para>
The behavior when an empty part was found changed with PHP 4.1.0. The old
behavior returned an empty string, while the new, correct, behavior
simply skips the part of the string:
<example>
<title>Old <function>strtok</function> behavior</title>
<programlisting role="php">
</programlisting>
</example>
</para>
<para>
The behavior when an empty part was found changed with PHP 4.1.0. The old
behavior returned an empty string, while the new, correct, behavior
simply skips the part of the string:
</para>
<para>
<example>
<title>Old <function>strtok</function> behavior</title>
<programlisting role="php">
<![CDATA[
<?php
$first_token = strtok('/something', '/');
@ -62,20 +101,18 @@ $second_token = strtok('/');
var_dump($first_token, $second_token);
?>
]]>
</programlisting>
<para>
Output:
</para>
<screen>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
string(0) ""
string(9) "something"
]]>
</screen>
</example>
<example>
<title>New <function>strtok</function> behavior</title>
<programlisting role="php">
</screen>
</example>
<example>
<title>New <function>strtok</function> behavior</title>
<programlisting role="php">
<![CDATA[
<?php
$first_token = strtok('/something', '/');
@ -83,25 +120,35 @@ $second_token = strtok('/');
var_dump($first_token, $second_token);
?>
]]>
</programlisting>
<para>
Output:
</para>
<screen>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
string(9) "something"
bool(false)
]]>
</screen>
</example>
</para>
&return.falseproblem;
<para>
See also <function>split</function> and
<function>explode</function>.
</para>
</refsect1>
</refentry>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
&return.falseproblem;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>split</function></member>
<member><function>explode</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:

View file

@ -1,84 +1,165 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strtr">
<refnamediv>
<refname>strtr</refname>
<refpurpose>Translate certain characters</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>strtr</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>from</parameter></methodparam>
<methodparam><type>string</type><parameter>to</parameter></methodparam>
</methodsynopsis>
<methodsynopsis>
<type>string</type><methodname>strtr</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>array</type><parameter>replace_pairs</parameter></methodparam>
</methodsynopsis>
<para>
This function returns a copy of <parameter>str</parameter>,
translating all occurrences of each character in
<parameter>from</parameter> to the corresponding character in
<parameter>to</parameter>.
</para>
<para>
If <parameter>from</parameter> and <parameter>to</parameter> are
different lengths, the extra characters in the longer of the two
are ignored.
<example>
<title><function>strtr</function> example</title>
<programlisting role="php">
<!-- $Revision: 1.7 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strtr" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>strtr</refname>
<refpurpose>Translate certain characters</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>strtr</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>from</parameter></methodparam>
<methodparam><type>string</type><parameter>to</parameter></methodparam>
</methodsynopsis>
<methodsynopsis>
<type>string</type><methodname>strtr</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>array</type><parameter>replace_pairs</parameter></methodparam>
</methodsynopsis>
<para>
This function returns a copy of <parameter>str</parameter>,
translating all occurrences of each character in
<parameter>from</parameter> to the corresponding character in
<parameter>to</parameter>.
</para>
<para>
If <parameter>from</parameter> and <parameter>to</parameter> are
different lengths, the extra characters in the longer of the two
are ignored.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>str</parameter></term>
<listitem>
<para>
The <type>string</type> being translated.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>from</parameter></term>
<listitem>
<para>
The <type>string</type> being translated to <parameter>to</parameter>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>to</parameter></term>
<listitem>
<para>
The <type>string</type> replacing <parameter>from</parameter>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>replace_pairs</parameter></term>
<listitem>
<para>
The <parameter>replace_pairs</parameter> parameter may be used as a substitute for
<parameter>to</parameter> and <parameter>from</parameter> in which case it's an
<type>array</type> in the form <literal>array('from' => 'to', ...)</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
This function returns a copy of <parameter>str</parameter>,
translating all occurrences of each character in
<parameter>from</parameter> to the corresponding character in
<parameter>to</parameter>.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>4.0.0</entry>
<entry>
The optional <parameter>to</parameter> and <parameter>from</parameter>
parameters were added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>strtr</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$addr = strtr($addr, "äåö", "aao");
?>
]]>
</programlisting>
</example>
</para>
<para>
<function>strtr</function> may be called with only two
arguments. If called with two arguments it behaves in a new way:
<parameter>from</parameter> then has to be an array that contains
string -> string pairs that will be replaced in the source
string. <function>strtr</function> will always look for the
longest possible match first and will *NOT* try to replace stuff
that it has already worked on.
</para>
<example>
<title><function>strtr</function> example with two arguments</title>
<programlisting role="php">
</programlisting>
</example>
</para>
<para>
<function>strtr</function> may be called with only two
arguments. If called with two arguments it behaves in a new way:
<parameter>from</parameter> then has to be an array that contains
string -> string pairs that will be replaced in the source
string. <function>strtr</function> will always look for the
longest possible match first and will *NOT* try to replace stuff
that it has already worked on.
</para>
<example>
<title><function>strtr</function> example with two arguments</title>
<programlisting role="php">
<![CDATA[
<?php
$trans = array("hello" => "hi", "hi" => "hello");
echo strtr("hi all, I said hello", $trans);
?>
]]>
</programlisting>
<para>
This will show:
</para>
<screen>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
hello all, I said hi
]]>
</screen>
</example>
<note>
<simpara>
This optional <parameter>to</parameter> and
<parameter>from</parameter> parameters were added in PHP 4.0.0
</simpara>
</note>
<para>
See also <function>ereg_replace</function>.
</para>
</refsect1>
</refentry>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>ereg_replace</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables: