Documentation and examples for crc32, sscanf, fscanf, headers_sent

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@29936 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jesus M. Castagnetto 2000-08-09 10:18:38 +00:00
parent 862448d51d
commit 1d5d76ee19
3 changed files with 174 additions and 4 deletions

View file

@ -1220,11 +1220,68 @@ fclose ($fd);
See also <function>fwrite</function>, <function>fopen</function>,
<function>fsockopen</function>, <function>popen</function>,
<function>fgets</function>, <function>fgetss</function>,
<function>fscanf</function>,
<function>file</function>, and <function>fpassthru</function>.
</simpara>
</refsect1>
</refentry>
<refentry id="function.fscanf">
<refnamediv>
<refname>fscanf</refname>
<refpurpose>Parses input from a file according to a format</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>mixed <function>fscanf</function></funcdef>
<paramdef>int <parameter>handle</parameter></paramdef>
<paramdef>string <parameter>format</parameter></paramdef>
<paramdef>string
<parameter><optional>var1</optional></parameter>...
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
The function <function>fscanf</function> is similar to
<function>sscanf</function>, but it takes its input from a file
associated with <parameter>handle</parameter> and interprets the input
according to the specified <parameter>format</parameter>. 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.
<example>
<title><function>Fscanf</function> Example</title>
<programlisting role="php">
$fp = fopen("users.txt","r");
while ($userinfo = fscanf($fp,"%s\t%s\t%s\n")) {
list($name, $profession, $countrycode) = $userinfo;
//... do something with the values
}
fclose($fp);
</programlisting>
</example>
<example>
<title>users.txt</title>
<programlisting>
javier argonaut pe
hiroshi sculptor jp
robert slacker us
luigi florist it
</programlisting>
</example>
</para>
<para>
See also <function>fread</function>,
<function>fgets</function>, <function>fgetss</function>,
<function>sscanf</function>, <function>printf</function>,
and <function>sprintf</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.fseek">
<refnamediv>
<refname>fseek</refname>

View file

@ -79,9 +79,37 @@ header ("Pragma: no-cache"); // HTTP/1.0
</programlisting>
</informalexample>
</para>
<para>
See also <function>headers_sent</function>
</para>
</refsect1>
</refentry>
<refentry id="function.headers-sent">
<refnamediv>
<refname>header_sent</refname>
<refpurpose>Returns true if headers have been sent</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>headers_sent</function></funcdef>
<paramdef><parameter>void</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
This function returns true if the HTTP headers have already been sent,
false otherwise.
</para>
<para>
See also <function>header</function>
</para>
</refsect1>
</refentry>
<refentry id="function.setcookie">
<refnamediv>
<refname>setcookie</refname>

View file

@ -862,6 +862,31 @@ $colon_separated = implode (":", $array);
</refsect1>
</refentry>
<refentry id="function.crc32">
<refnamediv>
<refname>crc32</refname>
<refpurpose>Calculates the crc32 polynomial of a string</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>crc32</function></funcdef>
<paramdef>string <parameter>str</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Generates the cyclic redundancy checksum polynomial of 32-bit lengths of
the <parameter>str</parameter>. This is usually used to validate the
integrity of data being trasmited.
</para>
<para>
See also: <function>md5</function>
</para>
</refsect1>
</refentry>
<refentry id="function.md5">
<refnamediv>
<refname>md5</refname>
@ -880,6 +905,9 @@ $colon_separated = implode (":", $array);
<ulink url="&url.rfc;rfc1321.html">RSA Data Security, Inc.
MD5 Message-Digest Algorithm</ulink>.
</para>
<para>
See also: <function>crc32</function>
</para>
</refsect1>
</refentry>
@ -1207,8 +1235,9 @@ echo $second[1]; /* prints "another" */
is described in the documentation for <function>sprintf</function>.
</simpara>
<simpara>
See also: <function>print</function>,
<function>sprintf</function>, and <function>flush</function>.
See also: <function>print</function>, <function>sprintf</function>,
<function>sscanf</function>, <function>fscanf</function>,
and <function>flush</function>.
</simpara>
</refsect1>
</refentry>
@ -1294,6 +1323,62 @@ $trimmed = rtrim ($line);
</refsect1>
</refentry>
<refentry id="function.sscanf">
<refnamediv>
<refname>sscanf</refname>
<refpurpose>Parses input from a string according to a format</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>mixed <function>sscanf</function></funcdef>
<paramdef>string <parameter>str</parameter></paramdef>
<paramdef>string <parameter>format</parameter></paramdef>
<paramdef>string
<parameter><optional>var1</optional></parameter>...
</paramdef>
</funcprototype>
</funcsynopsis>
<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>. If only two parameters were
passed to this function, the values parsed will be returned as an array.
<example>
<title><function>Sscanf</function> Example</title>
<programlisting role="php">
// getting the serial number
$serial = sscanf("SN/2350001","SN/%d");
// and the date of manufacturing
$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>
If optional parameters are passed, the function will return the number of
assigned values. The optional parameters must be passed by reference.
<example>
<title><function>Sscanf</function> - using optional parameters</title>
<programlisting role="php">
// get author info and generate DocBook entry
$auth = "24\tLewis Carroll";
$n = sscanf($auth,"%d\t%s %s", &amp;$id, &amp;$first, &amp;$last);
echo "&lt;author id='$id'&gt;
&lt;firstname&gt;$first&lt;/firstname&gt;
&lt;surname&gt;$last&lt;/surname&gt;
&lt;/author&gt;\n";
</programlisting>
</example>
</para>
<para>
See also: <function>fscanf</function>, <function>printf</function>,
and <function>sprintf</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.setlocale">
<refnamediv>
<refname>setlocale</refname>
@ -1562,8 +1647,8 @@ soundex ("Lukasiewicz") == soundex ("Lissajous") == 'L222';
</orderedlist>
</para>
<simpara>
See also: <function>printf</function> and
<function>number_format</function>.
See also: <function>printf</function>, <function>sscanf</function>,
<function>fscanf</function>, and <function>number_format</function>.
</simpara>
</refsect1>
<refsect1>