cvs: phpdoc-cs /appendices comparisons.xml filters.xml transports.xml
[email protected] ("Lukas Jelinek") Sat, 10 Jun 2006 14:03:22 -0000
| Newsgroups | php.doc.cs |
|---|---|
| Message-ID | <cvsluk1149948202@cvsserver> |
luk Sat Jun 10 14:03:22 2006 UTC
Added files:
/phpdoc-cs/appendices comparisons.xml filters.xml transports.xml
Log:
newly translated files
luk-20060610140322.txt
(text/plain, 42.4 KB)
http://cvs.php.net/viewcvs.cgi/phpdoc-cs/appendices/comparisons.xml?view=markup&rev=1.1
Index: phpdoc-cs/appendices/comparisons.xml
+++ phpdoc-cs/appendices/comparisons.xml
<?xml version="1.0" encoding="iso-8859-2"?>
<!-- EN-Revision: 1.9 Maintainer: luk Status: ready -->
<appendix id="types.comparisons">
<title>Tabulky porovnání datových typ? v PHP</title>
<para>
Následující tabulky ukazují chování PHP
<link linkend="language.types">typ?</link> a
<link linkend="language.operators.comparison">porovnávacích
operator?</link>, jak pro volné, tak pro striktní porovnávání.
Tento dopln?k se také vztahuje k manuálové sekci o
<link linkend="language.types.type-juggling">manipulaci s typy</link>.
Inspirace byla ?erpána z r?zných u?ivatelských komentá?? a z práce na
<ulink url="&url.blueshoes.comparisons;">BlueShoes</ulink>.
</para>
<para>
P?ed pou?itím t?chto tabulek je d?le?ité pochopit typy a jejich významy.
Nap?íklad <literal>"42"</literal> je <type>string</type> (?et?zec), kde?to
<literal>42</literal> je <type>integer</type> (ceké ?íslo). &false; je
<type>boolean</type>, kde?to <literal>"false"</literal> je
<type>string</type>.
</para>
<note>
<para>
HTML formulá?e nep?edávají celá ?ísla, ?ísla v plovoucí ?ádové ?árce
ani pravdivostní hodnoty; p?edávají ?et?zce. Ke zji?t?ní, zda se jedná
o ?íselný ?et?zec, m??ete pou?ít funkci
<function>is_numeric</function>.
</para>
</note>
<note>
<para>
Jednoduché <literal>if ($x)</literal>, kdy? <varname>$x</varname> není
definováno, vygeneruje chybu úrovn? <constant>E_NOTICE</constant>.
Namísto toho zvolte pou?ití <function>empty</function> nebo
<function>isset</function> a/nebo své prom?nné inicializujte.
</para>
</note>
<para>
<table>
<title>Porovnání <varname>$x</varname> v PHP funkcích</title>
<tgroup cols="6">
<thead>
<row>
<entry>Výraz</entry>
<entry><function>gettype</function></entry>
<entry><function>empty</function></entry>
<entry><function>is_null</function></entry>
<entry><function>isset</function></entry>
<entry><type>boolean</type> : <literal>if($x)</literal></entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>$x = "";</literal></entry>
<entry><type>string</type></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>$x = &null;</literal></entry>
<entry><type>NULL</type></entry>
<entry>&true;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>var $x;</literal></entry>
<entry><type>NULL</type></entry>
<entry>&true;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><varname>$x</varname> není definováno</entry>
<entry><type>NULL</type></entry>
<entry>&true;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>$x = array();</literal></entry>
<entry><type>array</type></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>$x = false;</literal></entry>
<entry><type>boolean</type></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>$x = true;</literal></entry>
<entry><type>boolean</type></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><literal>$x = 1;</literal></entry>
<entry><type>integer</type></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><literal>$x = 42;</literal></entry>
<entry><type>integer</type></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><literal>$x = 0;</literal></entry>
<entry><type>integer</type></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>$x = -1;</literal></entry>
<entry><type>integer</type></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><literal>$x = "1";</literal></entry>
<entry><type>string</type></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><literal>$x = "0";</literal></entry>
<entry><type>string</type></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>$x = "-1";</literal></entry>
<entry><type>string</type></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><literal>$x = "php";</literal></entry>
<entry><type>string</type></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><literal>$x = "true";</literal></entry>
<entry><type>string</type></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><literal>$x = "false";</literal></entry>
<entry><type>string</type></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Volné porovnání pomocí <literal>==</literal></title>
<tgroup cols="12">
<thead>
<row>
<entry> </entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry><literal>1</literal></entry>
<entry><literal>0</literal></entry>
<entry><literal>-1</literal></entry>
<entry><literal>"1"</literal></entry>
<entry><literal>"0"</literal></entry>
<entry><literal>"-1"</literal></entry>
<entry>&null;</entry>
<entry><literal>array()</literal></entry>
<entry><literal>"php"</literal></entry>
</row>
</thead>
<tbody>
<row>
<entry>&true;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
</row>
<row>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>1</literal></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>0</literal></entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
</row>
<row>
<entry><literal>-1</literal></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>"1"</literal></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>"0"</literal></entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>"-1"</literal></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>NULL</literal></entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>array()</literal></entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>"php"</literal></entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
<table>
<title>Striktní porovnání pomocí <literal>===</literal></title>
<tgroup cols="12">
<thead>
<row>
<entry> </entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry><literal>1</literal></entry>
<entry><literal>0</literal></entry>
<entry><literal>-1</literal></entry>
<entry><literal>"1"</literal></entry>
<entry><literal>"0"</literal></entry>
<entry><literal>"-1"</literal></entry>
<entry>&null;</entry>
<entry><literal>array()</literal></entry>
<entry><literal>"php"</literal></entry>
</row>
</thead>
<tbody>
<row>
<entry>&true;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>1</literal></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>0</literal></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>-1</literal></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>"1"</literal></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>"0"</literal></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>"-1"</literal></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry>&null;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>array()</literal></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>"php"</literal></entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&false;</entry>
<entry>&true;</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<note>
<title>Poznámka pro PHP 3.0</title>
<para>
Hodnota ?et?zce <literal>"0"</literal> se v PHP 3 pova?uje za neprázdnou.
V PHP 4 se toto chování zm?nilo a ?et?zec je nyní pova?ován za prázdný.
</para>
</note>
</appendix>
<!-- 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:"../../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
-->
http://cvs.php.net/viewcvs.cgi/phpdoc-cs/appendices/filters.xml?view=markup&rev=1.1
Index: phpdoc-cs/appendices/filters.xml
+++ phpdoc-cs/appendices/filters.xml
<?xml version="1.0" encoding="iso-8859-2"?>
<!-- EN-Revision: 1.14 Maintainer: luk Status: mixed -->
<appendix id="filters">
<title>Seznam dostupných filtr?</title>
<para>
Toto je seznam n?kolika vestav?ných streamových filtr? pro pou?ití
s <function>stream_filter_append</function>. Va?e verze PHP m??e
obsahovat více (nebo mén?) filtr?, ne? je zde uvedeno.
</para>
<para>
It is worth noting a slight asymmetry between
<function>stream_filter_append</function>
and <function>stream_filter_prepend</function>.
Every PHP stream contains a small <emphasis>read buffer</emphasis>
where it stores blocks of data retrieved from the
filesystem or other resource in order to process data
in the most efficient manner. As soon as data is pulled
from the resource into the stream's internal buffer, it
is immediately processed through any attached filters whether
the PHP application is actually ready for the data or not.
If data is sitting in the read buffer when a filter is
<emphasis>appended</emphasis>, this data will be immediately
processed through that filter making the fact that it was
sitting in the buffer seem transparent. However, if data is
sitting in the read buffer when a filter is
<emphasis>prepended</emphasis>, this data will <emphasis>NOT</emphasis>
be processed through that filter. It will instead wait until
the next block of data is retrieved from the resource.
</para>
<para>
For a list of filters installed in your version of
PHP use <function>stream_get_filters</function>.
</para>
<section id="filters.string">
<title>String Filters</title>
<simpara>
Each of these filters does precisely what their name implies and
correspond to the behavior of a built-in php string handling function.
For more information on a given filter, refer to the manual page for
the corresponding function.
</simpara>
<simpara>
<literal>string.rot13</literal>
(since PHP 4.3.0)
Use of this filter is equivalent to processing all stream data through
the <function>str_rot13</function> function.
</simpara>
<example>
<title>string.rot13</title>
<programlisting role="php">
<![CDATA[
<?php
$fp = fopen('php://output', 'w');
stream_filter_append($fp, 'string.rot13');
fwrite($fp, "This is a test.\n");
/* Outputs: Guvf vf n grfg. */
?>
]]>
</programlisting>
</example>
<simpara>
<literal>string.toupper</literal>
(since PHP 5.0.0)
Use of this filter is equivalent to processing all stream data through
the <function>strtoupper</function> function.
</simpara>
<example>
<title>string.toupper</title>
<programlisting role="php">
<![CDATA[
<?php
$fp = fopen('php://output', 'w');
stream_filter_append($fp, 'string.toupper');
fwrite($fp, "This is a test.\n");
/* Outputs: THIS IS A TEST. */
?>
]]>
</programlisting>
</example>
<simpara>
<literal>string.tolower</literal>
(since PHP 5.0.0)
Use of this filter is equivalent to processing all stream data through
the <function>strtolower</function> function.
</simpara>
<example>
<title>string.tolower</title>
<programlisting role="php">
<![CDATA[
<?php
$fp = fopen('php://output', 'w');
stream_filter_append($fp, 'string.tolower');
fwrite($fp, "This is a test.\n");
/* Outputs: this is a test. */
?>
]]>
</programlisting>
</example>
<simpara>
<literal>string.strip_tags</literal>
(since PHP 5.0.0)
Use of this filter is equivalent to processing all stream data through
the <function>strip_tags</function> function.
It accepts parameters in one of two forms:
Either as a string containing a list of tags similar to the
second parameter of the <function>strip_tags</function> function,
or as an array of tag names.
</simpara>
<example>
<title>string.strip_tags</title>
<programlisting role="php">
<![CDATA[
<?php
$fp = fopen('php://output', 'w');
stream_filter_append($fp, 'string.strip_tags', STREAM_FILTER_WRITE, "<b><i><u>");
fwrite($fp, "<b>bolded text</b> enlarged to a <h1>level 1 heading</h1>\n");
fclose($fp);
/* Outputs: <b>bolded text</b> enlarged to a level 1 heading */
$fp = fopen('php://output', 'w');
stream_filter_append($fp, 'string.strip_tags', STREAM_FILTER_WRITE, array('b','i','u'));
fwrite($fp, "<b>bolded text</b> enlarged to a <h1>level 1 heading</h1>\n");
fclose($fp);
/* Outputs: <b>bolded text</b> enlarged to a level 1 heading */
?>
]]>
</programlisting>
</example>
</section>
<section id="filters.convert">
<title>Conversion Filters</title>
<simpara>
Like the string.* filters, the convert.* filters perform actions
similar to their names. The convert filters were added with
PHP 5.0.0.
For more information on a given filter, refer to the manual page for
the corresponding function.
</simpara>
<simpara>
<literal>convert.base64-encode</literal> and
<literal>convert.base64-decode</literal>
Use of these filters are equivalent to processing all stream data through
the <function>base64_encode</function> and <function>base64_decode</function>
functions respectively.
<literal>convert.base64-encode</literal> supports parameters given as
an associative array. If <parameter>line-length</parameter> is given, the
base64 output will be split into chunks of <parameter>line-length</parameter>
characters each. If <parameter>line-break-chars</parameter> is given, each
chunk will be delimited by the characters given. These parameters give the
same effect as using <function>base64_encode</function> with
<function>chunk_split</function>.
</simpara>
<example>
<title>
convert.base64-encode &
convert.base64-decode
</title>
<programlisting role="php">
<![CDATA[
<?php
$fp = fopen('php://output', 'w');
stream_filter_append($fp, 'convert.base64-encode');
fwrite($fp, "This is a test.\n");
fclose($fp);
/* Outputs: VGhpcyBpcyBhIHRlc3QuCg== */
$param = array('line-length' => 8, 'line-break-chars' => "\r\n");
$fp = fopen('php://output', 'w');
stream_filter_append($fp, 'convert.base64-encode', STREAM_FILTER_WRITE, $param);
fwrite($fp, "This is a test.\n");
fclose($fp);
/* Outputs: VGhpcyBp
: cyBhIHRl
: c3QuCg== */
$fp = fopen('php://output', 'w');
stream_filter_append($fp, 'convert.base64-decode');
fwrite($fp, "VGhpcyBpcyBhIHRlc3QuCg==");
fclose($fp);
/* Outputs: This is a test. */
?>
]]>
</programlisting>
</example>
<simpara>
<literal>convert.quoted-printable-encode</literal> and
<literal>convert.quoted-printable-decode</literal>
Use of the decode version of this filter is equivalent to processing all stream
data through the <function>quoted_printable_decode</function> functions.
There is no function equivalent to <literal>convert.quoted-printable-encode</literal>.
<literal>convert.quoted-printable-encode</literal> supports parameters given as
an associative array. In addition to the parameters supported by
<literal>convert.base64-encode</literal>, <literal>convert.quoted-printable-encode</literal>
also supports boolean arguments <parameter>binary</parameter> and
<parameter>force-encode-first</parameter>.
<literal>convert.base64-decode</literal> only supports the
<parameter>line-break-chars</parameter> parameter as a type-hint
for striping from the encoded payload.
</simpara>
<example>
<title>
convert.quoted-printable-encode &
convert.quoted-printable-decode
</title>
<programlisting role="php">
<![CDATA[
<?php
$fp = fopen('php://output', 'w');
stream_filter_append($fp, 'convert.quoted-printable-encode');
fwrite($fp, "This is a test.\n");
/* Outputs: =This is a test.=0A */
?>
]]>
</programlisting>
</example>
</section>
<section id="filters.compression">
<title>Compression Filters</title>
<simpara>
While the <link linkend="wrappers.compression">Compression Wrappers</link>
provide a way of creating
gzip and bz2 compatible files on the local filesystem, they do not provide a
means for generalized compression over network streams, nor do they provide a
means to begin with a non-compressed stream and transition to a compressed one.
For this, a compression filter may be applied to any stream resource at any time.
</simpara>
<note>
<simpara>
Compression filters do <emphasis>not</emphasis> generate headers and trailers
used by commandline utilites such as <literal>gzip</literal>. They only compress
and decompress the payload portions of compressed data streams.
</simpara>
</note>
<simpara>
<literal>zlib.deflate</literal> (compression) and
<literal>zlib.inflate</literal> (decompression) are implementations of
the compression methods described in <ulink url="&url.rfc;1951">RFC 1951</ulink>.
The <literal>deflate</literal> filter takes up to three parameters passed as
an associative array.
<parameter>level</parameter> describes the compression
strength to use (1-9). Higher numbers will generally yield smaller payloads at
the cost of additional processing time. Two special compression levels also exist:
0 (for no compression at all), and -1 (zlib internal default -- currently 6).
<parameter>window</parameter> is the base-2 log of the compression loopback window size.
Higher values (up to 15 -- 32768 bytes) yield better compression at a cost of memory,
while lower values (down to 9 -- 512 bytes) yield worse compression in a smaller memory footprint.
Default <parameter>window</parameter> size is currently <constant>15</constant>.
<parameter>memory</parameter> is a scale indicating how much work memory should be allocated.
Valid values range from 1 (minimal allocation) to 9 (maximum allocation). This memory allocation
affects speed only and does not impact the size of the generated payload.
</simpara>
<note>
<simpara>
Because compression level is the most commonly used parameter, it may be alternatively
provided as a simple integer value (rather than an array element).
</simpara>
</note>
<simpara>
zlib.* compression filters are available with PHP as of version <literal>5.1.0</literal> if
<link linkend="ref.zlib">zlib</link> support is enabled. They are also available as a backport in version
<literal>5.0.x</literal> by installing the <ulink url="&url.pecl.package;zlib_filter">zlib_filter</ulink>
package from <ulink url="&url.pecl;">PECL</ulink>. These filters are <emphasis>not</emphasis>
available for PHP 4.
</simpara>
<example>
<title>
<literal>zlib.deflate</literal> and
<literal>zlib.inflate</literal>
</title>
<programlisting role="php">
<![CDATA[
<?php
$params = array('level' => 6, 'window' => 15, 'memory' => 9);
$original_text = "This is a test.\nThis is only a test.\nThis is not an important string.\n";
echo "The original text is " . strlen($original_text) . " characters long.\n";
$fp = fopen('test.deflated', 'w');
stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $params);
fwrite($fp, $original_text);
fclose($fp);
echo "The compressed file is " . filesize('test.deflated') . " bytes long.\n";
echo "The original text was:\n";
/* Use readfile and zlib.inflate to decompress on the fly */
readfile('php://filter/zlib.inflate/resource=test.deflated');
/* Generates output:
The original text is 70 characters long.
The compressed file is 56 bytes long.
The original text was:
This is a test.
This is only a test.
This is not an important string.
*/
?>
]]>
</programlisting>
</example>
<example>
<title>
jednoduché <literal>zlib.deflate</literal>
</title>
<programlisting role="php">
<![CDATA[
<?php
$original_text = "Toto je test.\nToto je pouze test.\nToto není d?le?itý ?et?zec.\n";
echo "P?vodní text je " . strlen($original_text) . " znak? dlouhý.\n";
$fp = fopen('test.deflated', 'w');
/* zde "6" indikuje úrove? komprese 6 */
stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, 6);
fwrite($fp, $original_text);
fclose($fp);
echo "Komprimovaný soubor je " . filesize('test.deflated') . " B velký.\n";
/* Generates output:
P?vodní text je 70 znak? dlouhý.
Komprimovaný soubor je 56 B velký.
*/
?>
]]>
</programlisting>
</example>
<simpara>
<literal>bzip2.compress</literal> a
<literal>bzip2.decompress</literal>
pracují stejným zp?sobem jako filtry zlib popsané vý?e.
Filtr <literal>bzip2.compress</literal> p?ijímá a? dva parametry poskytnuté
jako prvky asociativního pole:
<parameter>blocks</parameter> je hodnota typu integer od 1 do 9, udávající
po?et 100KB blok? pam?ti, které se alokují pro zpracování.
<parameter>work</parameter> je také typu integer, a to v rozmezí 0 a? 250.
?íká, jak velké úsilí se má vynalo?it s normální kompresní metodou, ne?
se p?ejde na pomalej?í, ale spolehliv?j?í metodu. Lad?ní tohoto parametru
má vliv pouze na rychlost komprese. Nem?ní se tím ani velikost komprimovaného
výstupu, ani vyu?ití pam?ti. Hodnota 0 znamená, ?e knihovna bzip pou?ije
vnit?ní výchozí hodnotu.
Filtr <literal>bzip2.decompress</literal> p?ijímá pouze jeden parametr,
který se p?edává bu? jako normální pravdivostní hodnota, nebo jako prvek
<parameter>small</parameter> v asociativním poli.
<parameter>small</parameter>, pokud má hodnotu &true;, ?íká knihovn? bzip,
?e se má k dekompresi pou?ít minimální mno?ství pam?ti na úkor rychlosti.
</simpara>
<simpara>
Kompresní filtry bzip2.* jsou dostupné od verze <literal>5.1.0</literal>,
pokud je zapnuta podpora <link linkend="ref.bzip2">bz2</link>.
Jsou dostupné té? jako backport ve verzi <literal>5.0.x</literal>
po nainstalování balíku
<ulink url="&url.pecl.package;bz2_filter">bz2_filter</ulink>
z <ulink url="&url.pecl;">PECL</ulink>. Tyto filtry
<emphasis>nejsou</emphasis> dostupné v PHP 4.
</simpara>
<example>
<title>
<literal>bzip2.compress</literal> a
<literal>bzip2.decompress</literal>
</title>
<programlisting role="php">
<![CDATA[
<?php
$param = array('blocks' => 9, 'work' => 0);
echo "P?vodní soubor je " . filesize('LICENSE') . " B velký.\n";
$fp = fopen('LICENSE.compressed', 'w');
stream_filter_append($fp, 'bzip2.compress', STREAM_FILTER_WRITE, $param);
fwrite($fp, file_get_contents('LICENSE'));
fclose($fp);
echo "Komprimovaný soubor je " . filesize('LICENSE.compressed') . " B velký.\n";
/* Vygenerovaný výstup:
P?vodní soubor je 3288 B velký.
Komprimovaný soubor je 1488 B velký.
*/
?>
]]>
</programlisting>
</example>
</section>
<section id="filters.encryption">
<title>?ifrovací filtry</title>
<simpara>
<literal>mcrypt.*</literal> a <literal>mdecrypt.*</literal>
poskytují symetrické ?ifrování a de?ifrování pomocí libmcrypt.
Ob? sady filtr? podporují stejné algoritmy dostupné pro
<link linkend="ref.mcrypt">mcrypt extension</link> ve form?
<literal>mcrypt.ciphername</literal>, kde <parameter>ciphername</parameter>
je název ?ifry, jak byl p?edán do funkce
<function>mcrypt_module_open</function>.
K dispozici je také t?chto p?t parametr? filtru:
</simpara>
<para>
<table>
<title>parametry filtru mcrypt</title>
<tgroup cols="4">
<thead>
<row>
<entry>Parametr</entry>
<entry>Vy?adován?</entry>
<entry>Výchozí</entry>
<entry>Ukázky hodnot</entry>
</row>
</thead>
<tbody>
<row>
<entry>mode</entry>
<entry>nepovinný</entry>
<entry>cbc</entry>
<entry>cbc, cfb, ecb, nofb, ofb, stream</entry>
</row>
<row>
<entry>algorithms_dir</entry>
<entry>nepovinný</entry>
<entry>ini_get('mcrypt.algorithms_dir')</entry>
<entry>Umíst?ní modul? algoritm?</entry>
</row>
<row>
<entry>modes_dir</entry>
<entry>nepovinný</entry>
<entry>ini_get('mcrypt.modes_dir')</entry>
<entry>Umíst?ní modul? re?im?</entry>
</row>
<row>
<entry>iv</entry>
<entry>povinný</entry>
<entry>N/A</entry>
<entry>Typicky 8, 16, nebo 32 B binárnách dat. Zále?í na ?if?e.</entry>
</row>
<row>
<entry>key</entry>
<entry>npovinný</entry>
<entry>N/A</entry>
<entry>Typicky 8, 16, nebo 32 B binárnách dat. Zále?í na ?if?e.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<example>
<title>?ifrování souboru pomocí 3DES</title>
<programlisting role="php">
<![CDATA[
<?php
$passphrase = 'My secret';
/* P?eve? lidsky ?itelné heslo
* na reprodukovatelný pár iv/key
*/
$iv = substr(md5('iv'.$passphrase, true), 0, 8);
$key = substr(md5('pass1'.$passphrase, true) .
md5('pass2'.$passphrase, true), 0, 24);
$opts = array('iv'=>$iv, 'key'=>$key);
$fp = fopen('secert-file.enc', 'wb');
stream_filter_append($fp, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts);
fwrite($fp, 'Secret secret secret data');
fclose($fp);
?>
]]>
</programlisting>
</example>
<example>
<title>?tení za?ifrovaného souboru</title>
<programlisting role="php">
<![CDATA[
<?php
$passphrase = 'My secret';
/* P?eve? lidsky ?itelné heslo
* na reprodukovatelný pár iv/key
*/
$iv = substr(md5('iv'.$passphrase, true), 0, 8);
$key = substr(md5('pass1'.$passphrase, true) .
md5('pass2'.$passphrase, true), 0, 24);
$opts = array('iv'=>$iv, 'key'=>$key);
$fp = fopen('secert-file.enc', 'rb');
stream_filter_append($fp, 'mdecrypt.tripledes', STREAM_FILTER_WRITE, $opts);
$data = rtrim(stream_get_contents($fp));
fclose($fp);
echo $data;
?>
]]>
</programlisting>
</example>
</section>
</appendix>
<!-- 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:"../../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
-->
http://cvs.php.net/viewcvs.cgi/phpdoc-cs/appendices/transports.xml?view=markup&rev=1.1
Index: phpdoc-cs/appendices/transports.xml
+++ phpdoc-cs/appendices/transports.xml
<?xml version="1.0" encoding="iso-8859-2"?>
<!-- EN-Revision: 1.12 Maintainer: luk Status: ready -->
<appendix id="transports">
<title>Seznam podporovaných socketových transport?</title>
<para>
Toto je seznam r?zných socketových transport? v URL stylu, které byly
vestav?ny do PHP k pou?ití se socketovými funkcemi zalo?enými na
streamech, jako je <function>fsockopen</function> a
<function>stream_socket_client</function>. Tyto transporty
<emphasis>nelze</emphasis> pou?ít s roz?í?ením
<link linkend="ref.sockets">Sockets Extension</link>.
</para>
<para>
K získání seznamu transport? instalovaných ve va?í verzi PHP
pou?ijte funkci <function>stream_get_transports</function>.
</para>
<section id="transports.inet">
<title>Internetová oblast: TCP, UDP, SSL a TLS</title>
<simpara>
PHP 3, PHP 4, PHP 5.
<literal>ssl://</literal> & <literal>tls://</literal> od PHP 4.3.0
<literal>sslv2://</literal> & <literal>sslv3://</literal> od PHP 5.0.2
</simpara>
<note>
<simpara>
Není-li specifikován ?ádný transport, p?edpokládá se <literal>tcp://</literal>.
</simpara>
</note>
<itemizedlist>
<listitem><simpara><literal>127.0.0.1</literal></simpara></listitem>
<listitem><simpara><literal>fe80::1</literal></simpara></listitem>
<listitem><simpara><literal>www.example.com</literal></simpara></listitem>
<listitem><simpara><literal>tcp://127.0.0.1</literal></simpara></listitem>
<listitem><simpara><literal>tcp://fe80::1</literal></simpara></listitem>
<listitem><simpara><literal>tcp://www.example.com</literal></simpara></listitem>
<listitem><simpara><literal>udp://www.example.com</literal></simpara></listitem>
<listitem><simpara><literal>ssl://www.example.com</literal></simpara></listitem>
<listitem><simpara><literal>sslv2://www.example.com</literal></simpara></listitem>
<listitem><simpara><literal>sslv3://www.example.com</literal></simpara></listitem>
<listitem><simpara><literal>tls://www.example.com</literal></simpara></listitem>
</itemizedlist>
<simpara>
Internetové sockety o?ekávají spolu s cílovou adresou ?íslo portu.
V p?ípad? funkce <function>fsockopen</function> se port specifikuje
v samostatném parametru a proto nemá vliv na formátování URL transportu.
U <function>stream_socket_client</function> a souvisejících funkcí,
podobn? jako u tradi?ních URL, se v?ak ?íslo portu specifikuje
p?idáním k URL transportu (a odd?luje se dvojte?kou).
</simpara>
<itemizedlist>
<listitem><simpara><literal>tcp://127.0.0.1:80</literal></simpara></listitem>
<listitem><simpara><literal>tcp://[fe80::1]:80</literal></simpara></listitem>
<listitem><simpara><literal>tcp://www.example.com:80</literal></simpara></listitem>
</itemizedlist>
<note>
<title>?íselné adresy IPv6 s ?ísly port?</title>
<simpara>
Ve druhém p?íkladu vý?e, p?esto?e p?íklady pro IPv4 a jmennou
adresu jsou ponechány nedot?ené p?i p?idání dvojte?ky a ?ísla
portu, adresa IPv6 je uzav?ena do hranatých závorek:
<literal>[fe80::1]</literal>. Je to kv?li rozli?ení mezi dvojte?kami
pou?itými v IPv6 adrese a tou, která odd?luje ?íslo portu.
</simpara>
</note>
<simpara>
Transporty <literal>ssl://</literal> a <literal>tls://</literal>
(dostupné pouze v p?ípad?, ?e se do PHP zakompiluje podpora OpenSSL)
jsou roz?í?ením transportu <literal>tcp://</literal>, které zahrnuje
podporu SLL ?ifrování. Zatímco v PHP 4.3.0 se musí podpora OpenSSL
kompilovat do PHP staticky, od verze PHP 5.0.0 ji lze kompilovat
staticky i jako modul.
</simpara>
<simpara>
<literal>ssl://</literal> se bude pokou?et vyjednat spojení SSL V2 nebo
SSL V3, v zále?itosti na schopnostech a nastavení vzdáleného stroje.
<literal>sslv2://</literal> a <literal>sslv3://</literal>
explicitn? vybere protokol SSL V2 nebo SSL V3.
</simpara>
<para>
<table>
<title>
Kontextové volby pro <literal>ssl://</literal> a <literal>tls://</literal>
transporty (od PHP 4.3.2)
</title>
<tgroup cols="3">
<thead>
<row>
<entry>Název</entry>
<entry>Pou?ití</entry>
<entry>Výchozí</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>verify_peer</literal></entry>
<entry>
&true; or &false;.
Vy?ádá ov??ení pou?itého SSL certifikátu.
</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>allow_self_signed</literal></entry>
<entry>
&true; or &false;.
Povolí pou?ití certifikátu podepsaného sebou samotným.
</entry>
<entry>&false;</entry>
</row>
<row>
<entry><literal>cafile</literal></entry>
<entry>
Umíst?ní souboru certifika?ních autorit, který by se m?l pou?ívat
v kontextu funkce <literal>verify_peer</literal> k ov??ení
toto?nosti vzdáleného stroje, v místní souborovém
systému.
</entry>
<entry></entry>
</row>
<row>
<entry><literal>capath</literal></entry>
<entry>
Pokud <literal>cafile</literal> není specifikován nebo tam nelze
certifikát najít, bude se pou?itelný certifikát hledat v adresá?i
ur?eném <literal>capath</literal>. <literal>capath</literal>
musí být správn? hashovaný adresá? s certifikáty.
</entry>
<entry></entry>
</row>
<row>
<entry><literal>local_cert</literal></entry>
<entry>
Cesta v souborovém systému k souboru místního certifikátu.
Musí to být soubor zakódovaný PEM, obsahující vá? certifikát
a soukromý klí?. Voliteln? m??e obsahovat i certifikátový ?et?z
vydavatel?.
</entry>
<entry></entry>
</row>
<row>
<entry><literal>passphrase</literal></entry>
<entry>
Heslo, kterým byl zakódován vá? soubor <literal>local_cert</literal>.
</entry>
<entry></entry>
</row>
<row>
<entry><literal>CN_match</literal></entry>
<entry>
O?ekávaná polo?ka Common Name (CN). PHP proveden omezenou
kontrolu pomocí wildcards. Nevyhoví-li Common Name, pokus
o spojení sel?e.
</entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<note>
<simpara>
Proto?e <literal>ssl://</literal> je bázový transport pro wrappery
<link linkend="wrappers.http"><literal>https://</literal></link> a
<link linkend="wrappers.ftp"><literal>ftps://</literal></link>,
jakékoli kontextové volby vztahující se k <literal>ssl://</literal>
se vztahují také na
<literal>https://</literal> a <literal>ftps://</literal>.
</simpara>
</note>
</section>
<section id="transports.unix">
<title>Unixová oblast: Unix a UDG</title>
<simpara>
<literal>unix://</literal> od PHP 3,
<literal>udg://</literal> od PHP 5
</simpara>
<itemizedlist>
<listitem><simpara><literal>unix:///tmp/mysock</literal></simpara></listitem>
<listitem><simpara><literal>udg:///tmp/mysock</literal></simpara></listitem>
</itemizedlist>
<simpara>
<literal>unix://</literal> poskytuje p?ístup k socketovému streamovému
spojení v unixové oblasti (domén?). <literal>udg://</literal> poskytuje
alternativní transport na socket v unixovové oblasti za pou?ití
u?ivatelského datagramového protokolu.
</simpara>
<simpara>
Unixové sockety, narozdíl od socket? internetových, neo?ekávají
?íslo portu. U funkce <function>fsockopen</function> by m?l být parametr
<parameter>portno</parameter> nastaven na nulu (0).
</simpara>
</section>
</appendix>
<!-- 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:"../../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
-->