cvs: phpdoc-cs /reference/strings/functions addslashes.xml htmlspecialchars.xml md5.xml nl2br.xml parse-str.xml str-replace.xml stripslashes.xml
stristr.xml strlen.xml strpos.xml strrchr.xml strrpos.xml strstr.xml strtr.xml substr.xml trim.xml /reference/url/functions rawurlencode.xml
urldecode.xml
| From: | Jakub Vrana | Date: | Fri, 02 Jan 2004 18:06:12 +0000 |
| Subject: | cvs: phpdoc-cs /reference/strings/functions addslashes.xml htmlspecialchars.xml md5.xml nl2br.xml parse-str.xml str-replace.xml stripslashes.xml stristr.xml strlen.xml strpos.xml strrchr.xml strrpos.xml strstr.xml strtr.xml substr.xml trim.xml /reference/url/functions rawurlencode.xml urldecode.xml |
||
| Groups: | php.doc.cs | ||
| Request: | Send a blank email to doc-cs+get-101@lists.php.net to get a copy of this message | ||
vrana Fri Jan 2 13:06:12 2004 EDT
Modified files:
/phpdoc-cs/reference/strings/functions addslashes.xml
htmlspecialchars.xml md5.xml
nl2br.xml parse-str.xml
str-replace.xml
stripslashes.xml stristr.xml
strlen.xml strpos.xml
strrchr.xml strrpos.xml
strstr.xml strtr.xml
substr.xml trim.xml
/phpdoc-cs/reference/url/functions rawurlencode.xml urldecode.xml
Log:
Up to dated
Index: phpdoc-cs/reference/strings/functions/addslashes.xml diff -u phpdoc-cs/reference/strings/functions/addslashes.xml:1.2 phpdoc-cs/reference/strings/functions/addslashes.xml:1.3 --- phpdoc-cs/reference/strings/functions/addslashes.xml:1.2 Tue Jun 11 17:47:37 2002 +++ phpdoc-cs/reference/strings/functions/addslashes.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'addslashes' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.addslashes"> <refnamediv> <refname>addslashes</refname> @@ -18,15 +17,49 @@ (<literal>'</literal>), dvojitá uvozovka (<literal>"</literal>), zpìtné lomítko (<literal>\</literal>) a NUL (&null; byte). </para> - <note> - <para> - <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> výchozí hodnota je ON. - </para> - </note> <para> - Viz také: <function>stripslashes</function>, - <function>htmlspecialchars</function> a - <function>quotemeta</function>. + Pøíklad pou¾ití funkce <function>addslashes</function> je kdy¾ + vkládáte data do databáze. Napøíklad pøi vlo¾ení jména + <literal>O'reilly</literal> do databáze musíte tento øetìzec escapovat. + Vìt¹ina databází pro to pou¾ívá znak <literal>\</literal>, z èeho¾ + vyjde <literal>O\'reilly</literal>. To se pou¾ije pouze pro vlo¾ení + do databáze, lomítka navíc nebudou ulo¾ena. + Nastavení PHP direktivy <link linkend="ini.magic-quotes-sybase"> + magic_quotes_sybase</link> na <literal>on</literal> zpùsobí, ¾e + znak <literal>'</literal> je místo lomítka escapován dal¹ím znakem + <literal>'</literal>. + </para> + <para> + PHP direktiva <link linkend="ini.magic-quotes-gpc"> + magic_quotes_gpc</link> je výchozím nastavení nastavena na <literal>on</literal>, co¾ zpùsobí + ¾e funkce <function>addslashes</function> bude pou¾ita na v¹echna data GET, POST a + COOKIE. Nepou¾ívejte funkci <function>addslashes</function> na + øetìzce, které ji¾ byly escapovány díky direktivì + <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link>, jinak + zpùsobíte dvojité escapování. Funkce + <function>get_magic_quotes_gpc</function> se mù¾e hodit, pro ovìøení + nastavení této direktivy. + </para> + <para> + <example> + <title>Pøíklad funkce <function>addslashes</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = "Jmenuje¹ se O'reilly?"; + +// Vypí¹e: Jmenuje¹ se O\'reilly? +echo addslashes($str); +?> +]]> + </programlisting> + </example> + </para> + <para> + Viz také <function>stripslashes</function>, + <function>htmlspecialchars</function>, + <function>quotemeta</function> a + <function>get_magic_quotes_gpc</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/htmlspecialchars.xml diff -u phpdoc-cs/reference/strings/functions/htmlspecialchars.xml:1.1 phpdoc-cs/reference/strings/functions/htmlspecialchars.xml:1.2 --- phpdoc-cs/reference/strings/functions/htmlspecialchars.xml:1.1 Sun Apr 14 19:48:09 2002 +++ phpdoc-cs/reference/strings/functions/htmlspecialchars.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'htmlspecialchars' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.7 Maintainer: luk Status: ready --> <refentry id="function.htmlspecialchars"> <refnamediv> <refname>htmlspecialchars</refname> @@ -12,6 +11,7 @@ <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> </methodsynopsis> <para> Nìkteré znaky mají v HTML zvlá¹tní význam, a pokud si mají zachovat bì¾ný @@ -63,7 +63,12 @@ <example> <title>Ukázka <function>htmlspecialchars</function></title> <programlisting role="php"> -$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); +<![CDATA[ +<?php +$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); +echo $new; // <a href='test'>Test</a> +?> +]]> </programlisting> </example> </para> @@ -73,8 +78,14 @@ Volitelný druhý argument byl pøidán v PHP 3.0.17 a PHP 4.0.3. </para> <para> - Viz také: <function>htmlentities</function> a - <function>nl2br</function>. + Tøetí parametr <parameter>charset</parameter> definuje kódovou stránku + pou¾itou pro pøevod. Výchozí kódová stránka je ISO-8859-1. Tøetí parametr + je k dispozici od PHP 4.1.0. + </para> + <para> + Viz také <function>get_html_translation_table</function>, + <function>strip_tags</function>, + <function>htmlentities</function> a <function>nl2br</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/md5.xml diff -u phpdoc-cs/reference/strings/functions/md5.xml:1.1 phpdoc-cs/reference/strings/functions/md5.xml:1.2 --- phpdoc-cs/reference/strings/functions/md5.xml:1.1 Sun Apr 14 19:48:10 2002 +++ phpdoc-cs/reference/strings/functions/md5.xml Fri Jan 2 13:06:11 2004 @@ -1,25 +1,51 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'md5' in en/ tree in rev 1.135 --> +<!-- EN-Revision: 1.7 Maintainer: luk Status: ready --> <refentry id="function.md5"> <refnamediv> <refname>md5</refname> - <refpurpose>Spoèítat MD5 XXX hash øetìzce</refpurpose> + <refpurpose>Spoèítat MD5 hash øetìzce</refpurpose> </refnamediv> <refsect1> <title>Popis</title> <methodsynopsis> <type>string</type><methodname>md5</methodname> <methodparam><type>string</type><parameter>str</parameter></methodparam> + <methodparam choice='opt'><type>bool</type><parameter>raw_output</parameter></methodparam> </methodsynopsis> <para> - Spoèítá MD5 XXX hash argumentu <parameter>str</parameter> pomocí - <ulink url="&url.rfc;rfc1321.html">MD5 Message-Digest Algoritmu spoleènosti - RSA Data Security, Inc.</ulink>. + Spoèítá MD5 hash argumentu <parameter>str</parameter> pomocí + <ulink url="&url.rfc;1321">MD5 Message-Digest Algoritmu spoleènosti + RSA Data Security, Inc.</ulink> a vrátí tento hash. Pokud je volitelný parametr + <parameter>raw_output</parameter> nastaven na &true;, je vrácen md5 otisk + v binárním formátu délky 16 bytù. + </para> + <note> + <simpara> + Volitelný parametr <parameter>raw_output</parameter> byl pøidán ve verzi + PHP 5.0.0 a jeho výchozí hodnota je &false; + </simpara> + </note> + <para> + <example> + <title>Pøíklad <function>md5</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = 'apple'; + +if (md5($str) === '1f3870be274f6c49b3e31a0c6728957f') { + echo "Pøejete si zelené nebo èervené jablko?"; + exit; +} +?> +]]> + </programlisting> + </example> + </para> + <para> + Viz také <function>crc32</function>, <function>md5_file</function> + a <function>sha1</function>. </para> - <para> - Viz také: <function>crc32</function>. - </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/nl2br.xml diff -u phpdoc-cs/reference/strings/functions/nl2br.xml:1.1 phpdoc-cs/reference/strings/functions/nl2br.xml:1.2 --- phpdoc-cs/reference/strings/functions/nl2br.xml:1.1 Sun Apr 14 19:48:10 2002 +++ phpdoc-cs/reference/strings/functions/nl2br.xml Fri Jan 2 13:06:11 2004 @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'nl2br' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.nl2br"> <refnamediv> <refname>nl2br</refname> - <refpurpose>Pøevede konce øádkù na HTML konce øádkù</refpurpose> + <refpurpose>Pøed v¹echny konce øádkù v øetìzci vlo¾í HTML konce øádkù</refpurpose> </refnamediv> <refsect1> <title>Popis</title> @@ -14,12 +13,42 @@ </methodsynopsis> <para> Vrací <parameter>string</parameter>, ve kterém je pøed ka¾dý konec øádku - vlo¾en tag '<BR>'. + vlo¾ena znaèka '<br />'. </para> + <note> <para> - Viz také: <function>htmlspecialchars</function>, - <function>htmlentities</function> a - <function>wordwrap</function>. + Od PHP 4.0.5, je funkce <function>nl2br</function> XHTML + zpùsobilá. V¹echny verze pøed 4.0.5 vrátí + <parameter>string</parameter> se znaèkou '<br>' vlo¾enou pøed + konce øádkù místo '<br />'. + </para> + </note> + <para> + <example> + <title>Pou¾ití <function>nl2br</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +echo nl2br("foo není\n bar"); +?> +]]> + </programlisting> + <para> + Vypí¹e: + </para> + <screen> +<![CDATA[ +foo není<br /> + bar +]]> + </screen> + </example> + </para> + <para> + Viz také <function>htmlspecialchars</function>, + <function>htmlentities</function>, + <function>wordwrap</function> a + <function>str_replace</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/parse-str.xml diff -u phpdoc-cs/reference/strings/functions/parse-str.xml:1.1 phpdoc-cs/reference/strings/functions/parse-str.xml:1.2 --- phpdoc-cs/reference/strings/functions/parse-str.xml:1.1 Sun Apr 14 19:48:10 2002 +++ phpdoc-cs/reference/strings/functions/parse-str.xml Fri Jan 2 13:06:11 2004 @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'parse-str' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.parse-str"> <refnamediv> <refname>parse_str</refname> - <refpurpose>Roparsovat øetìzec do promìnných</refpurpose> + <refpurpose>Rozparsovat øetìzec do promìnných</refpurpose> </refnamediv> <refsect1> <title>Popis</title> @@ -14,23 +13,50 @@ <methodparam choice="opt"><type>array</type><parameter>arr</parameter></methodparam> </methodsynopsis> <para> - Rozparsuje øetìzec jako kdyby to byl querystring pøedaný v URL a definuje - pøíslu¹né promìnné v souèasném scope. Pokud je pøedán druhý argument + Rozparsuje øetìzec jako kdyby to byl query-string pøedaný v URL a definuje + pøíslu¹né promìnné v souèasném rozsahu platnosti. Pokud je pøedán druhý argument <parameter>arr</parameter>, promìnné se místo toho ulo¾í do této promìnné jako pole. </para> + <note> + <para> + Volitelný druhý parametr je k dispozici od PHP 4.0.3. + </para> + </note> + <note> + <para> + Pro získání aktuálního <emphasis>QUERY_STRING</emphasis>, mo¾ná budete muset pou¾ít promìnnou + <link linkend="reserved.variables.server">$_SERVER['QUERY_STRING']</link>. + Mo¾ná vás také bude zajímat kapitola + <link linkend="language.variables.external">promìnné mimo PHP</link>. + </para> + </note> <para> <example> - <title>Using <function>parse_str</function></title> + <title>Pou¾ití <function>parse_str</function></title> <programlisting role="php"> -$str = "first=value&second[]=this+works&second[]=another"; +<![CDATA[ +<?php +$str = "first=value&arr[]=foo+bar&arr[]=baz"; parse_str($str); -echo $first; /* vytiskne "value" */ -echo $second[0]; /* vytiskne "this works" */ -echo $second[1]; /* vytiskne "another" */ +echo $first; // value +echo $arr[0]; // foo bar +echo $arr[1]; // baz + +parse_str($str, $output); +echo $output['first']; // value +echo $output['arr'][0]; // foo bar +echo $output['arr'][1]; // baz + +?> +]]> </programlisting> </example> </para> + <para> + Viz také <function>parse_url</function>, <function>pathinfo</function>, + <function>set_magic_quotes_runtime</function> a <function>urldecode</function>. + </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/str-replace.xml diff -u phpdoc-cs/reference/strings/functions/str-replace.xml:1.1 phpdoc-cs/reference/strings/functions/str-replace.xml:1.2 --- phpdoc-cs/reference/strings/functions/str-replace.xml:1.1 Sun Apr 14 19:48:12 2002 +++ phpdoc-cs/reference/strings/functions/str-replace.xml Fri Jan 2 13:06:11 2004 @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'str-replace' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.12 Maintainer: luk Status: ready --> <refentry id="function.str-replace"> <refnamediv> <refname>str_replace</refname> <refpurpose> - Nahradit v¹echny výskyty jednoho øetìzce v jiném dal¹ím øetìzcem + Nahradit v¹echny výskyty jednoho øetìzce dal¹ím øetìzcem </refpurpose> </refnamediv> <refsect1> @@ -15,32 +14,95 @@ <methodparam><type>string</type><parameter>needle</parameter></methodparam> <methodparam><type>string</type><parameter>str</parameter></methodparam> <methodparam><type>string</type><parameter>haystack</parameter></methodparam> + <methodparam choice="opt"><type>int</type><parameter>&count</parameter></methodparam> </methodsynopsis> <para> Tato funkce nahradí v¹echny výskyty <parameter>needle</parameter> v argumentu <parameter>haystack</parameter> argumentem <parameter>str</parameter>. Pokud nepotøebujete slo¾itá pravidla pro nahrazování, mìli byste v¾dy pou¾ít - tuto funkci místo <function>ereg_replace</function>. + tuto funkci místo <function>ereg_replace</function> nebo + <function>preg_replace</function>. + </para> + <para> + Od PHP 4.0.5 mù¾e být ka¾dý parametr funkce <function>str_replace</function> + typu <type>array</type>. + </para> + <warning> + <simpara> + V PHP verzích star¹ích ne¾ 4.3.3 byla chyba pøi pou¾ívání polí + v parametrech <parameter>search</parameter> a zároveò <parameter>replace</parameter>, + která zpùsobila, ¾e prázdné polo¾ky pole <parameter>search</parameter> + byly pøeskoèeny bez zvý¹ení interního ukazatele v + poli <parameter>replace</parameter>. Bylo to opraveno v + <literal>PHP 4.3.3</literal>. V¹echny skripty, které na tuto chybu spoléhaly, + by mìly pøed zavoláním této funkce odstranit prázdné hodnoty vyhledávání, + aby nasimulovaly pùvodní chování. + </simpara> + </warning> + <para> + Pokud je parametr <parameter>subject</parameter> pole, probìhne vyhledávání + a nahrazení v ka¾dé polo¾ce pole + <parameter>subject</parameter> a návratová hodnota je + také pole. + </para> + <para> + Pokud jsou parametry <parameter>search</parameter> a + <parameter>replace</parameter> pole, funkce + <function>str_replace</function> bere hodnoty tìchto polí + a pou¾ívá je pro vyhledávání a nahrazení v parametru + <parameter>subject</parameter>. Pokud má parametr + <parameter>replace</parameter> ménì hodnot ne¾ parametr + <parameter>search</parameter>, tak se pro chybìjící hodnoty pou¾ije + prázdný øetìzec. Pokud je parametr <parameter>search</parameter> + pole a parametr <parameter>replace</parameter> je øetìzec, tak se + tento øetìzec pou¾ije pro ka¾dou hodnotu parametru + <parameter>search</parameter>. </para> <para> <example> <title>Ukázka <function>str_replace</function></title> <programlisting role="php"> -$bodytag = str_replace ("%body%", "black", "<body text=%body%>"); +<![CDATA[ +<?php +// Vrátí: <body text='black'> +$bodytag = str_replace("%body%", "black", "<body text='%body%'>"); + +// Vrátí: Hll Wrld f PHP +$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U"); +$onlyconsonants = str_replace($vowels, "", "Hello World of PHP"); + +// Vrátí: You should eat pizza, beer, and ice cream every day +$phrase = "You should eat fruits, vegetables, and fiber every day."; +$healthy = array("fruits", "vegetables", "fiber"); +$yummy = array("pizza", "beer", "ice cream"); + +$newphrase = str_replace($healthy, $yummy, $phrase); + +// Parametr count je k dispozici od PHP 5.0.0 +$str = str_replace("ll", "", "good golly miss molly!", $count); +echo $count; // 2 +?> +]]> </programlisting> </example> </para> - <para> - Tato funkce je XXX binárnì bezpeèná. - </para> + + ¬e.bin-safe; + <note> - <para> - Funkce <function>str_replace</function> byla pøidána v PHP 3.0.6, ale a¾ - do verze PHP 3.0.8 fungovala ¹patnì. - </para> + <simpara> + Od <literal>PHP 5.0.0</literal> je poèet nalezených a zamìnìných + øetìzcù (<parameter>search</parameter>) vrácen v parametru + <parameter>count</parameter>, který je pøedáván referencí. + Pøed <literal>PHP 5.0.0</literal> není tento parametr k dispozici. + </simpara> </note> <para> - Viz také: <function>ereg_replace</function> a + Viz také + <function>str_ireplace</function>, + <function>substr_replace</function>, + <function>ereg_replace</function>, + <function>preg_replace</function> a <function>strtr</function>. </para> </refsect1> Index: phpdoc-cs/reference/strings/functions/stripslashes.xml diff -u phpdoc-cs/reference/strings/functions/stripslashes.xml:1.1 phpdoc-cs/reference/strings/functions/stripslashes.xml:1.2 --- phpdoc-cs/reference/strings/functions/stripslashes.xml:1.1 Sun Apr 14 19:48:12 2002 +++ phpdoc-cs/reference/strings/functions/stripslashes.xml Fri Jan 2 13:06:11 2004 @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'stripslashes' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.stripslashes"> <refnamediv> <refname>stripslashes</refname> <refpurpose> - Un-quote string quoted with <function>addslashes</function> + Zru¹it escapování provedené funkcí <function>addslashes</function> </refpurpose> </refnamediv> <refsect1> @@ -15,12 +14,37 @@ <methodparam><type>string</type><parameter>str</parameter></methodparam> </methodsynopsis> <para> - Vrací øetìzec bez odstranìných zpìtných lomítek. + Vrací øetìzec s odstranìnými zpìtnými lomítky. (<literal>\'</literal> se stává <literal>'</literal> a pod.) - Zdvojená zpìtná lomítka se spojují do jednoduchých. + Zdvojená zpìtná lomítka (<literal>\\</literal>) se spojují do + jednoduchých (<literal>\</literal>). + </para> + <para> + Funkce <function>stripslashes</function> mù¾e být pou¾ita napøíklad tehdy, kdy¾ je PHP + direktiva <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> + nastavena na <literal>on</literal> (co¾ je výchozí nastavení) a vy + tato data nevkládáte na místa (jako je databáze), která toto escapování potøebují. + To je napøíklad tehdy, kdy¾ data zadaná do HTML formuláøe pouze + vypisujete. + </para> + <para> + <example> + <title>Pøíklad funkce <function>stripslashes</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = "Jmenuje¹ se O\'reilly?"; + +// Outputs: Jmenuje¹ se O'reilly? +echo stripslashes($str); +?> +]]> + </programlisting> + </example> </para> <simpara> - Viz také: <function>addslashes</function>. + Viz také <function>addslashes</function> a + <function>get_magic_quotes_gpc</function>. </simpara> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/stristr.xml diff -u phpdoc-cs/reference/strings/functions/stristr.xml:1.1 phpdoc-cs/reference/strings/functions/stristr.xml:1.2 --- phpdoc-cs/reference/strings/functions/stristr.xml:1.1 Sun Apr 14 19:48:12 2002 +++ phpdoc-cs/reference/strings/functions/stristr.xml Fri Jan 2 13:06:11 2004 @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'stristr' in en/ tree in rev 1.8 --> +<!-- EN-Revision: 1.5 Maintainer: luk Status: ready --> <refentry id="function.stristr"> <refnamediv> <refname>stristr</refname> <refpurpose> - Case-insensitive <function>strstr</function> + <function>strstr</function> bez rozli¹ení velikosti písmen </refpurpose> </refnamediv> <refsect1> @@ -26,12 +25,25 @@ </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. </para> <para> - Viz také: <function>strchr</function>, - <function>strrchr</function>, - <function>substr</function> a + <example> + <title>Pøíklad pou¾ití <function>stristr</function></title> + <programlisting role="php"> +<![CDATA[ +<?php + $email = 'USER@EXAMPLE.com'; + $domain = stristr($email, 'e'); + echo $domain; // ER@EXAMPLE.com +?> +]]> + </programlisting> + </example> + </para> + <para> + Viz také <function>strchr</function>, + <function>strrchr</function>, <function>substr</function> a <function>ereg</function>. </para> </refsect1> Index: phpdoc-cs/reference/strings/functions/strlen.xml diff -u phpdoc-cs/reference/strings/functions/strlen.xml:1.1 phpdoc-cs/reference/strings/functions/strlen.xml:1.2 --- phpdoc-cs/reference/strings/functions/strlen.xml:1.1 Sun Apr 14 19:48:12 2002 +++ phpdoc-cs/reference/strings/functions/strlen.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strlen' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.strlen"> <refnamediv> <refname>strlen</refname> @@ -15,6 +14,25 @@ <para> Vrací délku (poèet znakù) argumentu <parameter>string</parameter>. </para> + <para> + <example> + <title>Pøíklad funkce <function>strlen</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = 'abcdef'; +echo strlen($str); // 6 + +$str = ' ab cd '; +echo strlen($str); // 7 +?> +]]> + </programlisting> + </example> + </para> + <para> + Viz také <function>count</function>. + </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/strpos.xml diff -u phpdoc-cs/reference/strings/functions/strpos.xml:1.1 phpdoc-cs/reference/strings/functions/strpos.xml:1.2 --- phpdoc-cs/reference/strings/functions/strpos.xml:1.1 Sun Apr 14 19:48:14 2002 +++ phpdoc-cs/reference/strings/functions/strpos.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strpos' in en/ tree in rev 1.8 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.strpos"> <refnamediv> <refname>strpos</refname> @@ -23,40 +22,48 @@ </para> <para> Pokud <parameter>needle</parameter> nenajde, vrací &false;. - <note> - <para> - Návratové hodnoty "znak nalezen na pozici 0" a "znak nenalezen" se dají - snadno zamìnit. Tady je návod, jak zjistit tento rozdíl: - <informalexample> - <programlisting role="php"> -// v PHP 4.0b3 a novìj¹ích: -$pos = strpos ($mystring, "b"); -if ($pos === false) { // tøi rovnítka - // nenalezeno... -} + </para> + + &return.falseproblem; + + <para> + <example> + <title><function>strpos</function> examples</title> + <programlisting role="php"> +<![CDATA[ +<?php +$mystring = 'abc'; +$findme = 'a'; +$pos = strpos($mystring, $findme); -// ve verzích star¹ích ne¾ 4.0b3: -$pos = strpos ($mystring, "b"); -if (is_string ($pos) && !$pos) { - // nenalezeno... +// V¹imnìte si pou¾ití ===. Obyèejné == by nefungovalo podle pøedpokladu, +// proto¾e 'a' je na nultém (prvním) místì. +if ($pos === false) { + echo "Øetìzec '$findme' nebyl nalezen v øetìzci '$mystring'"; +} else { + echo "Øetìzec '$findme' nebyl nalezen v øetìzci '$mystring'"; + echo " a je na pozici $pos"; } - </programlisting> - </informalexample> - </para> - </note> + +?> +]]> + </programlisting> + </example> </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. </para> <para> - Volitelný argument <parameter>offset</parameter> vám umo¾òuje urèit na + Volitelný argument <parameter>offset</parameter> vám umo¾òuje urèit, na které pozici v <parameter>haystack</parameter> má hledání zaèít. Vrácená pozice je i tak relativní k zaèátku <parameter>haystack</parameter>. </para> <para> Viz také: <function>strrpos</function>, - <function>strrchr</function>, + <function>stripos</function>, + <function>strripos</function>, + <function>strrchr</function>, <function>substr</function>, <function>stristr</function> a <function>strstr</function>. Index: phpdoc-cs/reference/strings/functions/strrchr.xml diff -u phpdoc-cs/reference/strings/functions/strrchr.xml:1.1 phpdoc-cs/reference/strings/functions/strrchr.xml:1.2 --- phpdoc-cs/reference/strings/functions/strrchr.xml:1.1 Sun Apr 14 19:48:14 2002 +++ phpdoc-cs/reference/strings/functions/strrchr.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strrchr' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.strrchr"> <refnamediv> <refname>strrchr</refname> @@ -15,7 +14,7 @@ </methodsynopsis> <para> Tato funkce vrací tu èást <parameter>haystack</parameter>, která zaèíná - poslením výskytem <parameter>needle</parameter> a pokraèuje do konce + posledním výskytem <parameter>needle</parameter> a pokraèuje do konce <parameter>haystack</parameter>. </para> <para> @@ -23,27 +22,31 @@ </para> <para> Pokud <parameter>needle</parameter> obsahuje více ne¾ jeden znak, pou¾ije - se první z nich. + se první z nich. Toto chování je odli¹né od funkce + <function>strchr</function>. </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. <example> <title>Ukázka <function>strrchr</function></title> <programlisting role="php"> +<![CDATA[ +<?php // získat poslední adresáø v $PATH -$dir = substr (strrchr ($PATH, ":"), 1); +$dir = substr(strrchr($PATH, ":"), 1); // získat v¹echno po posledním konci øádku $text = "Øádek 1\nØádek 2\nØádek 3"; -$last = substr (strrchr ($text, 10), 1 ); +$last = substr(strrchr($text, 10), 1 ); +?> +]]> </programlisting> </example> </para> <para> - Viz také: <function>substr</function>, - <function>stristr</function> a - <function>strstr</function>. + Viz také <function>strchr</function>, <function>substr</function>, + <function>stristr</function> a <function>strstr</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/strrpos.xml diff -u phpdoc-cs/reference/strings/functions/strrpos.xml:1.1 phpdoc-cs/reference/strings/functions/strrpos.xml:1.2 --- phpdoc-cs/reference/strings/functions/strrpos.xml:1.1 Sun Apr 14 19:48:14 2002 +++ phpdoc-cs/reference/strings/functions/strrpos.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strrpos' in en/ tree in rev 1.8 --> +<!-- EN-Revision: 1.9 Maintainer: luk Status: ready --> <refentry id="function.strrpos"> <refnamediv> <refname>strrpos</refname> @@ -12,11 +11,12 @@ <type>int</type><methodname>strrpos</methodname> <methodparam><type>string</type><parameter>haystack</parameter></methodparam> <methodparam><type>char</type><parameter>needle</parameter></methodparam> + <methodparam choice="opt"><type>int</type><parameter>offset</parameter></methodparam> </methodsynopsis> <para> Vrací èíselnou pozici posledního výskytu <parameter>needle</parameter> v - øetìzci <parameter>haystack</parameter>. <parameter>needle</parameter> mù¾e - být jen jeden znak dlouhá. Pokud obsahuje více znakù, pou¾ije se první z + øetìzci <parameter>haystack</parameter>. Øetìzec <parameter>needle</parameter> mù¾e + být v PHP 4 jen jeden znak dlouhý. Pokud obsahuje více znakù, pou¾ije se první z nich. </para> <para> @@ -27,17 +27,22 @@ snadno zamìnit. Tady je návod, jak zjistit tento rozdíl: <informalexample> <programlisting role="php"> +<![CDATA[ +<?php + // v PHP 4.0b3 a novìj¹ích: -$pos = strpos ($mystring, "b"); -if ($pos === false) { // tøi rovnítka +$pos = strrpos($mystring, "b"); +if ($pos === false) { // v¹imnìte si: tøi rovnítka // nenalezeno... } // ve verzích star¹ích ne¾ 4.0b3: -$pos = strpos ($mystring, "b"); -if (is_string ($pos) && !$pos) { +$pos = strrpos($mystring, "b"); +if (is_bool($pos) && !$pos) { // nenalezeno... } +?> +]]> </programlisting> </informalexample> </para> @@ -45,11 +50,26 @@ </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. </para> + <note> + <simpara> + Od <literal>PHP 5.0.0</literal> mù¾e být zadán parametr <parameter>offset</parameter>. + To zpùsobí, ¾e hledání zaène od urèité pozice v + øetìzci. Záporné hodnoty zastaví hledání na urèitém místì + pøed koncem øetìzce. + </simpara> + </note> + <note> + <simpara> + Parametr <parameter>needle</parameter> mù¾e být od <literal>PHP 5.0.0</literal> + øetìzec del¹í ne¾ 1 znak. + </simpara> + </note> <para> - Viz také: <function>strpos</function>, - <function>strrchr</function>, + Viz také <function>strpos</function>, + <function>strripos</function>, + <function>strrchr</function>, <function>substr</function>, <function>stristr</function> a <function>strstr</function>. Index: phpdoc-cs/reference/strings/functions/strstr.xml diff -u phpdoc-cs/reference/strings/functions/strstr.xml:1.1 phpdoc-cs/reference/strings/functions/strstr.xml:1.2 --- phpdoc-cs/reference/strings/functions/strstr.xml:1.1 Sun Apr 14 19:48:14 2002 +++ phpdoc-cs/reference/strings/functions/strstr.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strstr' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.6 Maintainer: luk Status: ready --> <refentry id="function.strstr"> <refnamediv> <refname>strstr</refname> @@ -22,12 +21,12 @@ </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. </para> <para> <note> <para> - Pozn.: tato funkce je case-sensitive. Pro case-insensitive hledání + Pozn.: tato funkce rozli¹uje velikost písmen. Pro hledání bez rozli¹ení velikosti písmen pou¾ijte <function>stristr</function>. </para> </note> @@ -36,17 +35,30 @@ <example> <title>Ukázka <function>strstr</function></title> <programlisting role="php"> -$email = 'sterling@designmultimedia.com'; -$domain = strstr ($email, '@'); -print $domain; // vytiskne @designmultimedia.com +<![CDATA[ +<?php +$email = 'user@example.com'; +$domain = strstr($email, '@'); +echo $domain; // @example.com +?> +]]> </programlisting> </example> </para> <para> - Viz také: <function>stristr</function>, - <function>strrchr</function>, - <function>substr</function> a - <function>ereg</function>. + <note> + <para> + Pokud pouze chcete zjistit, zda se urèitý øetìzec <parameter>needle</parameter> + vyskytuje v øetìzci <parameter>haystack</parameter>, je rychlej¹í a ménì nároèné + na pamì» pou¾ití funkce <function>strpos</function>. + </para> + </note> + </para> + <para> + Viz také <function>ereg</function>, <function>preg_match</function>, + <function>strchr</function>, <function>stristr</function>, + <function>strpos</function>, <function>strrchr</function> a + <function>substr</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/strtr.xml diff -u phpdoc-cs/reference/strings/functions/strtr.xml:1.1 phpdoc-cs/reference/strings/functions/strtr.xml:1.2 --- phpdoc-cs/reference/strings/functions/strtr.xml:1.1 Sun Apr 14 19:48:16 2002 +++ phpdoc-cs/reference/strings/functions/strtr.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strtr' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.strtr"> <refnamediv> <refname>strtr</refname> @@ -14,6 +13,11 @@ <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> Tato funkce upraví <parameter>str</parameter> tak, ¾e v¹echny výskyty v¹ech znakù ve <parameter>from</parameter> pøelo¾í na odpovídající znaky v @@ -25,7 +29,11 @@ <example> <title>Ukázka <function>strtr</function></title> <programlisting role="php"> +<![CDATA[ +<?php $addr = strtr($addr, "äåö", "aao"); +?> +]]> </programlisting> </example> </para> @@ -33,19 +41,28 @@ <function>strtr</function> se dá také volat pouze se dvìma argumenty. Pøi volání se dvìma argumenty se chová takto: <parameter>from</parameter> musí být pole obsahující páry øetìzcù, které se zamìní ve zdrojovém øetìzci. - <function>strtr</function> v¾dy hledá nejdel¹í mo¾nou shodu a *NENAHRAZUJE* + <function>strtr</function> v¾dy hledá nejdel¹í mo¾nou shodu a NENAHRAZUJE ty èásti øetìzce, na kterých u¾ pracovala. </para> - <para> - Ukázky: - <informalexample> + <example> + <title><function>strtr</function> example with two arguments</title> <programlisting role="php"> -$trans = array ("ahoj" => "nazdar", "nazdar" => "ahoj"); -echo strtr("nazdar lidi, øekl jsem ahoj", $trans) . "\n"; +<![CDATA[ +<?php +$trans = array("ahoj" => "nazdar", "nazdar" => "ahoj"); +echo strtr("nazdar lidi, øekl jsem ahoj", $trans); +?> +]]> </programlisting> - </informalexample> - Výsledek: "ahoj lidi, øekl jsem nazdar", + <para> + Výsledek: </para> + <screen> +<![CDATA[ +ahoj lidi, øekl jsem nazdar +]]> + </screen> + </example> <note> <simpara> Tato vlastnost (dva argumenty) byla pøidána v PHP 4.0. Index: phpdoc-cs/reference/strings/functions/substr.xml diff -u phpdoc-cs/reference/strings/functions/substr.xml:1.1 phpdoc-cs/reference/strings/functions/substr.xml:1.2 --- phpdoc-cs/reference/strings/functions/substr.xml:1.1 Sun Apr 14 19:48:16 2002 +++ phpdoc-cs/reference/strings/functions/substr.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'substr' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.7 Maintainer: luk Status: ready --> <refentry id="function.substr"> <refnamediv> <refname>substr</refname> @@ -19,61 +18,79 @@ urèenou argumenty <parameter>start</parameter> a <parameter>length</parameter>. </para> <para> - Pokud je <parameter>start</parameter> pozitivní, vrácený øetìzec zaène + Pokud je <parameter>start</parameter> kladný, vrácený øetìzec zaène <parameter>start</parameter>-tým znakem øetìzce <parameter>string</parameter>, poèítáno od nuly. Napøíklad v øetìzci '<literal>abcdef</literal>' je znakem na <literal>0</literal>-té pozici '<literal>a</literal>', znakem na pozici <literal>2</literal> je '<literal>c</literal>', atd. </para> + <example> + <title>Základní pou¾ití <function>substr</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$rest = substr("abcdef", 1); // vrátí "bcdef" +$rest = substr("abcdef", 1, 3); // vrátí "bcd" +$rest = substr("abcdef", 0, 4); // vrátí "abcd" +$rest = substr("abcdef", 0, 8); // vrátí "abcdef" + +// Pøístup pøes slo¾ené závorky je dal¹í mo¾nost +$string = 'abcdef'; +echo $string{0}; // vrátí a +echo $string{3}; // vrátí d +?> +]]> + </programlisting> + </example> <para> - Pøíklady: - <informalexample> - <programlisting role="php"> -$rest = substr ("abcdef", 1); // vrátí "bcdef" -$rest = substr ("abcdef", 1, 3); // vrátí "bcd" - </programlisting> - </informalexample> - </para> - <para> - Pokud je <parameter>start</parameter> negativní, vrácený øetìzec zaène + Pokud je <parameter>start</parameter> záporný, vrácený øetìzec zaène <parameter>start</parameter>-tým znakem od konce argumentu <parameter>string</parameter>. </para> - <para> - Pøíklady: - <informalexample> - <programlisting role="php"> -$rest = substr ("abcdef", -1); // vrátí "f" -$rest = substr ("abcdef", -2); // vrátí "ef" -$rest = substr ("abcdef", -3, 1); // vrátí "d" - </programlisting> - </informalexample> - </para> + <example> + <title>Pou¾ití záporného èísla v parametru <parameter>start</parameter></title> + <programlisting role="php"> +<![CDATA[ +<?php +$rest = substr("abcdef", -1); // returns "f" +$rest = substr("abcdef", -2); // returns "ef" +$rest = substr("abcdef", -3, 1); // returns "d" +?> +]]> + </programlisting> + </example> <para> Pokud je argument <parameter>length</parameter> kladný, vrácený øetìzec - skonèí <parameter>length</parameter> znakù od <parameter>start</parameter>. - Pokud by to znamenalo øetìzec se zápornou délkou (<parameter>start</parameter> - je za <parameter>length</parameter>), vrácený øetìzec bude sestávat z - jediného znaku na pozici <parameter>start</parameter>. - </para> - <para> - Pokud je argument <parameter>length</parameter> kladný, vrácený øetìzec - skonèí <parameter>length</parameter> znakù od konce argumentu - <parameter>string</parameter>. Pokud by to znamenalo øetìzec se zápornou - délkou, vrácený øetìzec bude sestávat z jediného znaku na pozici - <parameter>start</parameter>. - </para> - <para> - Pøíklady: - <informalexample> - <programlisting role="php"> -$rest = substr ("abcdef", 1, -1); // vrátí "bcde" - </programlisting> - </informalexample> - </para> - <para> - Viz také: <function>strrchr</function> a - <function>ereg</function>. + skonèí <parameter>length</parameter> znakù za pozicí <parameter>start</parameter>. + Pokud je parametr <parameter>string</parameter> krat¹í + ne¾ <parameter>start</parameter> znakù, vrátí tato funkce + &false;. + </para> + <para> + Pokud je parametr <parameter>length</parameter> negativní, tak bude + z konce øetìzce <parameter>string</parameter> vynechán odpovídající poèet znakù. + Pokud parametr + <parameter>start</parameter> urèuje pozici za tímto zkrácením, + bude vrácen prázdný øetìzec. + </para> + <example> + <title>Pou¾ití záporného parametru <parameter>length</parameter></title> + <programlisting role="php"> +<![CDATA[ +<?php +$rest = substr("abcdef", 0, -1); // vrátí "abcde" +$rest = substr("abcdef", 2, -1); // vrátí "cde" +$rest = substr("abcdef", 4, -4); // vrátí "" +$rest = substr("abcdef", -3, -1); // vrátí "de" +?> +]]> + </programlisting> + </example> + <para> + Viz také <function>strrchr</function>, + <function>substr_replace</function>, + <function>ereg</function> a + <function>trim</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/trim.xml diff -u phpdoc-cs/reference/strings/functions/trim.xml:1.1 phpdoc-cs/reference/strings/functions/trim.xml:1.2 --- phpdoc-cs/reference/strings/functions/trim.xml:1.1 Sun Apr 14 19:48:16 2002 +++ phpdoc-cs/reference/strings/functions/trim.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'trim' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.trim"> <refnamediv> <refname>trim</refname> @@ -13,15 +12,88 @@ <methodsynopsis> <type>string</type><methodname>trim</methodname> <methodparam><type>string</type><parameter>str</parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>charlist</parameter></methodparam> </methodsynopsis> + <note> + <simpara> + Volitelný parametr <parameter>charlist</parameter> byl pøidán + v PHP 4.1.0 + </simpara> + </note> <para> - Tato funkce odstraòuje netisknutelné znaky ze zaèátku a konce øetìzce a - vrací øetìzec bez tìchto znakù. Netisknutelné znaky, které se v souèasnosti - odstraòují, jsou: "\n", "\r", "\t", "\v", "\0", a mezera. + Tato funkce odstraòuje bílé znaky ze zaèátku a konce øetìzce a + vrací øetìzec bez tìchto znakù. + Bez druhého parametru + odstraní tato funkce následující znaky: + <!-- sorted by importance. Printed 3 times: trim, ltrim, rtrim --> + <itemizedlist> + <listitem> + <simpara> + " " (<acronym>ASCII</acronym> <literal>32</literal> + (<literal>0x20</literal>)), obyèejná mezera. + </simpara> + </listitem> + <listitem> + <simpara> + "\t" (<acronym>ASCII</acronym> <literal>9</literal> + (<literal>0x09</literal>)), tabulátor. + </simpara> + </listitem> + <listitem> + <simpara> + "\n" (<acronym>ASCII</acronym> <literal>10</literal> + (<literal>0x0A</literal>)), nová øádka (line feed). + </simpara> + </listitem> + <listitem> + <simpara> + "\r" (<acronym>ASCII</acronym> <literal>13</literal> + (<literal>0x0D</literal>)), návrat vozíku (carriage return). + </simpara> + </listitem> + <listitem> + <simpara> + "\0" (<acronym>ASCII</acronym> <literal>0</literal> + (<literal>0x00</literal>)), znak <literal>NUL</literal>. + </simpara> + </listitem> + <listitem> + <simpara> <!-- not \v, since not supported by PHP --> + "\x0B" (<acronym>ASCII</acronym> <literal>11</literal> + (<literal>0x0B</literal>)), vertikální tabulátor. + </simpara> + </listitem> + </itemizedlist> </para> <para> - Viz také <function>chop</function>, <function>rtrim</function> a - <function>ltrim</function>. + Mù¾ete také urèit, které znaky chcete odstranit, a to pomocí + parametru <parameter>charlist</parameter>. + Jednodu¹e vyjmenujte v¹echny znaky, které chcete odstranit. Pomocí + <literal>..</literal> mù¾ete urèit rozsah znakù. + </para> + <example> + <title>Pøíklady pou¾ití <function>trim</function></title> + <para> + <programlisting role="php"> +<![CDATA[ +<?php + +$text = "\t\tZde je pár slov :) ... "; +$trimmed = trim($text); +// $trimmed = "Zde je pár slov :) ..." +$trimmed = trim($text, " \t."); +// $trimmed = "Zde je pár slov :)" +$clean = trim($binary, "\0x00..\0x1F"); +// odstranit kontrolní znaky ASCII ze zaèátku i konce promìnné $binary +// (od 0 do 31 vèetnì) + +?> +]]> + </programlisting> + </para> + </example> + <para> + Viz také <function>ltrim</function> a <function>rtrim</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/url/functions/rawurlencode.xml diff -u phpdoc-cs/reference/url/functions/rawurlencode.xml:1.1 phpdoc-cs/reference/url/functions/rawurlencode.xml:1.2 --- phpdoc-cs/reference/url/functions/rawurlencode.xml:1.1 Sun Apr 14 19:48:24 2002 +++ phpdoc-cs/reference/url/functions/rawurlencode.xml Fri Jan 2 13:06:12 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/url.xml, last change in rev 1.1 --> -<!-- last change to 'rawurlencode' in en/ tree in rev 1.6 --> +<!-- EN-Revision: 1.7 Maintainer: luk Status: ready --> <refentry id="function.rawurlencode"> <refnamediv> <refname>rawurlencode</refname> @@ -23,23 +22,32 @@ <example> <title>Pøíklad <function>rawurlencode</function> è. 1</title> <programlisting role="php"> -echo '<A HREF="ftp://user:', rawurlencode ('foo @+%/'), - '@ftp.my.com/x.txt">'; +<![CDATA[ +<?php +echo '<a href="ftp://user:', rawurlencode('foo @+%/'), + '@ftp.example.com/x.txt">'; +?> +]]> </programlisting> </example> - Nebo, pokud pøedáváte informace v komponentì URL obsahující info o cestì: + Nebo, pokud pøedáváte informace v komponentì URL obsahující informaci o cestì: <example> <title>Pøíklad <function>rawurlencode</function> è. 2</title> <programlisting role="php"> -echo '<A HREF="http://x.com/department_list_script/', - rawurlencode ('sales and marketing/Miami'), '">'; +<![CDATA[ +<?php +echo '<a href="http://example.com/department_list_script/', + rawurlencode('sales and marketing/Miami'), '">'; +?> +]]> </programlisting> </example> </para> <simpara> Viz také: <function>rawurldecode</function>, <function>urldecode</function>, - <function>urlencode</function>. + <function>urlencode</function> a + <ulink url="&url.rfc;1738">RFC 1738</ulink>. </simpara> </refsect1> </refentry> Index: phpdoc-cs/reference/url/functions/urldecode.xml diff -u phpdoc-cs/reference/url/functions/urldecode.xml:1.1 phpdoc-cs/reference/url/functions/urldecode.xml:1.2 --- phpdoc-cs/reference/url/functions/urldecode.xml:1.1 Sun Apr 14 19:48:24 2002 +++ phpdoc-cs/reference/url/functions/urldecode.xml Fri Jan 2 13:06:12 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/url.xml, last change in rev 1.1 --> -<!-- last change to 'urldecode' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.urldecode"> <refnamediv> <refname>urldecode</refname> @@ -18,20 +17,24 @@ <example> <title>Pøíklad <function>urldecode</function></title> <programlisting role="php"> -$a = split ('&', $querystring); +<![CDATA[ +<?php +$a = explode('&', $QUERY_STRING); $i = 0; -while ($i < count ($a)) { - $b = split ('=', $a [$i]); - echo 'Hodnota argumentu ', htmlspecialchars (urldecode ($b [0])), - ' je ', htmlspecialchars (urldecode ($b [1])), "<BR>"; +while ($i < count($a)) { + $b = split('=', $a[$i]); + echo 'Hodnota parametru ', htmlspecialchars(urldecode($b[0])), + ' je ', htmlspecialchars(urldecode($b[1])), "<br />\n"; $i++; } +?> +]]> </programlisting> </example> </para> <para> Viz také <function>urlencode</function>, - <function>rawurlencode</function>, + <function>rawurlencode</function> a <function>rawurldecode</function>. </para> </refsect1>
Index: phpdoc-cs/reference/strings/functions/addslashes.xml diff -u phpdoc-cs/reference/strings/functions/addslashes.xml:1.2 phpdoc-cs/reference/strings/functions/addslashes.xml:1.3 --- phpdoc-cs/reference/strings/functions/addslashes.xml:1.2 Tue Jun 11 17:47:37 2002 +++ phpdoc-cs/reference/strings/functions/addslashes.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'addslashes' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.addslashes"> <refnamediv> <refname>addslashes</refname> @@ -18,15 +17,49 @@ (<literal>'</literal>), dvojitá uvozovka (<literal>"</literal>), zpìtné lomítko (<literal>\</literal>) a NUL (&null; byte). </para> - <note> - <para> - <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> výchozí hodnota je ON. - </para> - </note> <para> - Viz také: <function>stripslashes</function>, - <function>htmlspecialchars</function> a - <function>quotemeta</function>. + Pøíklad pou¾ití funkce <function>addslashes</function> je kdy¾ + vkládáte data do databáze. Napøíklad pøi vlo¾ení jména + <literal>O'reilly</literal> do databáze musíte tento øetìzec escapovat. + Vìt¹ina databází pro to pou¾ívá znak <literal>\</literal>, z èeho¾ + vyjde <literal>O\'reilly</literal>. To se pou¾ije pouze pro vlo¾ení + do databáze, lomítka navíc nebudou ulo¾ena. + Nastavení PHP direktivy <link linkend="ini.magic-quotes-sybase"> + magic_quotes_sybase</link> na <literal>on</literal> zpùsobí, ¾e + znak <literal>'</literal> je místo lomítka escapován dal¹ím znakem + <literal>'</literal>. + </para> + <para> + PHP direktiva <link linkend="ini.magic-quotes-gpc"> + magic_quotes_gpc</link> je výchozím nastavení nastavena na <literal>on</literal>, co¾ zpùsobí + ¾e funkce <function>addslashes</function> bude pou¾ita na v¹echna data GET, POST a + COOKIE. Nepou¾ívejte funkci <function>addslashes</function> na + øetìzce, které ji¾ byly escapovány díky direktivì + <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link>, jinak + zpùsobíte dvojité escapování. Funkce + <function>get_magic_quotes_gpc</function> se mù¾e hodit, pro ovìøení + nastavení této direktivy. + </para> + <para> + <example> + <title>Pøíklad funkce <function>addslashes</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = "Jmenuje¹ se O'reilly?"; + +// Vypí¹e: Jmenuje¹ se O\'reilly? +echo addslashes($str); +?> +]]> + </programlisting> + </example> + </para> + <para> + Viz také <function>stripslashes</function>, + <function>htmlspecialchars</function>, + <function>quotemeta</function> a + <function>get_magic_quotes_gpc</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/htmlspecialchars.xml diff -u phpdoc-cs/reference/strings/functions/htmlspecialchars.xml:1.1 phpdoc-cs/reference/strings/functions/htmlspecialchars.xml:1.2 --- phpdoc-cs/reference/strings/functions/htmlspecialchars.xml:1.1 Sun Apr 14 19:48:09 2002 +++ phpdoc-cs/reference/strings/functions/htmlspecialchars.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'htmlspecialchars' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.7 Maintainer: luk Status: ready --> <refentry id="function.htmlspecialchars"> <refnamediv> <refname>htmlspecialchars</refname> @@ -12,6 +11,7 @@ <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> </methodsynopsis> <para> Nìkteré znaky mají v HTML zvlá¹tní význam, a pokud si mají zachovat bì¾ný @@ -63,7 +63,12 @@ <example> <title>Ukázka <function>htmlspecialchars</function></title> <programlisting role="php"> -$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); +<![CDATA[ +<?php +$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); +echo $new; // <a href='test'>Test</a> +?> +]]> </programlisting> </example> </para> @@ -73,8 +78,14 @@ Volitelný druhý argument byl pøidán v PHP 3.0.17 a PHP 4.0.3. </para> <para> - Viz také: <function>htmlentities</function> a - <function>nl2br</function>. + Tøetí parametr <parameter>charset</parameter> definuje kódovou stránku + pou¾itou pro pøevod. Výchozí kódová stránka je ISO-8859-1. Tøetí parametr + je k dispozici od PHP 4.1.0. + </para> + <para> + Viz také <function>get_html_translation_table</function>, + <function>strip_tags</function>, + <function>htmlentities</function> a <function>nl2br</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/md5.xml diff -u phpdoc-cs/reference/strings/functions/md5.xml:1.1 phpdoc-cs/reference/strings/functions/md5.xml:1.2 --- phpdoc-cs/reference/strings/functions/md5.xml:1.1 Sun Apr 14 19:48:10 2002 +++ phpdoc-cs/reference/strings/functions/md5.xml Fri Jan 2 13:06:11 2004 @@ -1,25 +1,51 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'md5' in en/ tree in rev 1.135 --> +<!-- EN-Revision: 1.7 Maintainer: luk Status: ready --> <refentry id="function.md5"> <refnamediv> <refname>md5</refname> - <refpurpose>Spoèítat MD5 XXX hash øetìzce</refpurpose> + <refpurpose>Spoèítat MD5 hash øetìzce</refpurpose> </refnamediv> <refsect1> <title>Popis</title> <methodsynopsis> <type>string</type><methodname>md5</methodname> <methodparam><type>string</type><parameter>str</parameter></methodparam> + <methodparam choice='opt'><type>bool</type><parameter>raw_output</parameter></methodparam> </methodsynopsis> <para> - Spoèítá MD5 XXX hash argumentu <parameter>str</parameter> pomocí - <ulink url="&url.rfc;rfc1321.html">MD5 Message-Digest Algoritmu spoleènosti - RSA Data Security, Inc.</ulink>. + Spoèítá MD5 hash argumentu <parameter>str</parameter> pomocí + <ulink url="&url.rfc;1321">MD5 Message-Digest Algoritmu spoleènosti + RSA Data Security, Inc.</ulink> a vrátí tento hash. Pokud je volitelný parametr + <parameter>raw_output</parameter> nastaven na &true;, je vrácen md5 otisk + v binárním formátu délky 16 bytù. + </para> + <note> + <simpara> + Volitelný parametr <parameter>raw_output</parameter> byl pøidán ve verzi + PHP 5.0.0 a jeho výchozí hodnota je &false; + </simpara> + </note> + <para> + <example> + <title>Pøíklad <function>md5</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = 'apple'; + +if (md5($str) === '1f3870be274f6c49b3e31a0c6728957f') { + echo "Pøejete si zelené nebo èervené jablko?"; + exit; +} +?> +]]> + </programlisting> + </example> + </para> + <para> + Viz také <function>crc32</function>, <function>md5_file</function> + a <function>sha1</function>. </para> - <para> - Viz také: <function>crc32</function>. - </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/nl2br.xml diff -u phpdoc-cs/reference/strings/functions/nl2br.xml:1.1 phpdoc-cs/reference/strings/functions/nl2br.xml:1.2 --- phpdoc-cs/reference/strings/functions/nl2br.xml:1.1 Sun Apr 14 19:48:10 2002 +++ phpdoc-cs/reference/strings/functions/nl2br.xml Fri Jan 2 13:06:11 2004 @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'nl2br' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.nl2br"> <refnamediv> <refname>nl2br</refname> - <refpurpose>Pøevede konce øádkù na HTML konce øádkù</refpurpose> + <refpurpose>Pøed v¹echny konce øádkù v øetìzci vlo¾í HTML konce øádkù</refpurpose> </refnamediv> <refsect1> <title>Popis</title> @@ -14,12 +13,42 @@ </methodsynopsis> <para> Vrací <parameter>string</parameter>, ve kterém je pøed ka¾dý konec øádku - vlo¾en tag '<BR>'. + vlo¾ena znaèka '<br />'. </para> + <note> <para> - Viz také: <function>htmlspecialchars</function>, - <function>htmlentities</function> a - <function>wordwrap</function>. + Od PHP 4.0.5, je funkce <function>nl2br</function> XHTML + zpùsobilá. V¹echny verze pøed 4.0.5 vrátí + <parameter>string</parameter> se znaèkou '<br>' vlo¾enou pøed + konce øádkù místo '<br />'. + </para> + </note> + <para> + <example> + <title>Pou¾ití <function>nl2br</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +echo nl2br("foo není\n bar"); +?> +]]> + </programlisting> + <para> + Vypí¹e: + </para> + <screen> +<![CDATA[ +foo není<br /> + bar +]]> + </screen> + </example> + </para> + <para> + Viz také <function>htmlspecialchars</function>, + <function>htmlentities</function>, + <function>wordwrap</function> a + <function>str_replace</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/parse-str.xml diff -u phpdoc-cs/reference/strings/functions/parse-str.xml:1.1 phpdoc-cs/reference/strings/functions/parse-str.xml:1.2 --- phpdoc-cs/reference/strings/functions/parse-str.xml:1.1 Sun Apr 14 19:48:10 2002 +++ phpdoc-cs/reference/strings/functions/parse-str.xml Fri Jan 2 13:06:11 2004 @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'parse-str' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.parse-str"> <refnamediv> <refname>parse_str</refname> - <refpurpose>Roparsovat øetìzec do promìnných</refpurpose> + <refpurpose>Rozparsovat øetìzec do promìnných</refpurpose> </refnamediv> <refsect1> <title>Popis</title> @@ -14,23 +13,50 @@ <methodparam choice="opt"><type>array</type><parameter>arr</parameter></methodparam> </methodsynopsis> <para> - Rozparsuje øetìzec jako kdyby to byl querystring pøedaný v URL a definuje - pøíslu¹né promìnné v souèasném scope. Pokud je pøedán druhý argument + Rozparsuje øetìzec jako kdyby to byl query-string pøedaný v URL a definuje + pøíslu¹né promìnné v souèasném rozsahu platnosti. Pokud je pøedán druhý argument <parameter>arr</parameter>, promìnné se místo toho ulo¾í do této promìnné jako pole. </para> + <note> + <para> + Volitelný druhý parametr je k dispozici od PHP 4.0.3. + </para> + </note> + <note> + <para> + Pro získání aktuálního <emphasis>QUERY_STRING</emphasis>, mo¾ná budete muset pou¾ít promìnnou + <link linkend="reserved.variables.server">$_SERVER['QUERY_STRING']</link>. + Mo¾ná vás také bude zajímat kapitola + <link linkend="language.variables.external">promìnné mimo PHP</link>. + </para> + </note> <para> <example> - <title>Using <function>parse_str</function></title> + <title>Pou¾ití <function>parse_str</function></title> <programlisting role="php"> -$str = "first=value&second[]=this+works&second[]=another"; +<![CDATA[ +<?php +$str = "first=value&arr[]=foo+bar&arr[]=baz"; parse_str($str); -echo $first; /* vytiskne "value" */ -echo $second[0]; /* vytiskne "this works" */ -echo $second[1]; /* vytiskne "another" */ +echo $first; // value +echo $arr[0]; // foo bar +echo $arr[1]; // baz + +parse_str($str, $output); +echo $output['first']; // value +echo $output['arr'][0]; // foo bar +echo $output['arr'][1]; // baz + +?> +]]> </programlisting> </example> </para> + <para> + Viz také <function>parse_url</function>, <function>pathinfo</function>, + <function>set_magic_quotes_runtime</function> a <function>urldecode</function>. + </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/str-replace.xml diff -u phpdoc-cs/reference/strings/functions/str-replace.xml:1.1 phpdoc-cs/reference/strings/functions/str-replace.xml:1.2 --- phpdoc-cs/reference/strings/functions/str-replace.xml:1.1 Sun Apr 14 19:48:12 2002 +++ phpdoc-cs/reference/strings/functions/str-replace.xml Fri Jan 2 13:06:11 2004 @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'str-replace' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.12 Maintainer: luk Status: ready --> <refentry id="function.str-replace"> <refnamediv> <refname>str_replace</refname> <refpurpose> - Nahradit v¹echny výskyty jednoho øetìzce v jiném dal¹ím øetìzcem + Nahradit v¹echny výskyty jednoho øetìzce dal¹ím øetìzcem </refpurpose> </refnamediv> <refsect1> @@ -15,32 +14,95 @@ <methodparam><type>string</type><parameter>needle</parameter></methodparam> <methodparam><type>string</type><parameter>str</parameter></methodparam> <methodparam><type>string</type><parameter>haystack</parameter></methodparam> + <methodparam choice="opt"><type>int</type><parameter>&count</parameter></methodparam> </methodsynopsis> <para> Tato funkce nahradí v¹echny výskyty <parameter>needle</parameter> v argumentu <parameter>haystack</parameter> argumentem <parameter>str</parameter>. Pokud nepotøebujete slo¾itá pravidla pro nahrazování, mìli byste v¾dy pou¾ít - tuto funkci místo <function>ereg_replace</function>. + tuto funkci místo <function>ereg_replace</function> nebo + <function>preg_replace</function>. + </para> + <para> + Od PHP 4.0.5 mù¾e být ka¾dý parametr funkce <function>str_replace</function> + typu <type>array</type>. + </para> + <warning> + <simpara> + V PHP verzích star¹ích ne¾ 4.3.3 byla chyba pøi pou¾ívání polí + v parametrech <parameter>search</parameter> a zároveò <parameter>replace</parameter>, + která zpùsobila, ¾e prázdné polo¾ky pole <parameter>search</parameter> + byly pøeskoèeny bez zvý¹ení interního ukazatele v + poli <parameter>replace</parameter>. Bylo to opraveno v + <literal>PHP 4.3.3</literal>. V¹echny skripty, které na tuto chybu spoléhaly, + by mìly pøed zavoláním této funkce odstranit prázdné hodnoty vyhledávání, + aby nasimulovaly pùvodní chování. + </simpara> + </warning> + <para> + Pokud je parametr <parameter>subject</parameter> pole, probìhne vyhledávání + a nahrazení v ka¾dé polo¾ce pole + <parameter>subject</parameter> a návratová hodnota je + také pole. + </para> + <para> + Pokud jsou parametry <parameter>search</parameter> a + <parameter>replace</parameter> pole, funkce + <function>str_replace</function> bere hodnoty tìchto polí + a pou¾ívá je pro vyhledávání a nahrazení v parametru + <parameter>subject</parameter>. Pokud má parametr + <parameter>replace</parameter> ménì hodnot ne¾ parametr + <parameter>search</parameter>, tak se pro chybìjící hodnoty pou¾ije + prázdný øetìzec. Pokud je parametr <parameter>search</parameter> + pole a parametr <parameter>replace</parameter> je øetìzec, tak se + tento øetìzec pou¾ije pro ka¾dou hodnotu parametru + <parameter>search</parameter>. </para> <para> <example> <title>Ukázka <function>str_replace</function></title> <programlisting role="php"> -$bodytag = str_replace ("%body%", "black", "<body text=%body%>"); +<![CDATA[ +<?php +// Vrátí: <body text='black'> +$bodytag = str_replace("%body%", "black", "<body text='%body%'>"); + +// Vrátí: Hll Wrld f PHP +$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U"); +$onlyconsonants = str_replace($vowels, "", "Hello World of PHP"); + +// Vrátí: You should eat pizza, beer, and ice cream every day +$phrase = "You should eat fruits, vegetables, and fiber every day."; +$healthy = array("fruits", "vegetables", "fiber"); +$yummy = array("pizza", "beer", "ice cream"); + +$newphrase = str_replace($healthy, $yummy, $phrase); + +// Parametr count je k dispozici od PHP 5.0.0 +$str = str_replace("ll", "", "good golly miss molly!", $count); +echo $count; // 2 +?> +]]> </programlisting> </example> </para> - <para> - Tato funkce je XXX binárnì bezpeèná. - </para> + + ¬e.bin-safe; + <note> - <para> - Funkce <function>str_replace</function> byla pøidána v PHP 3.0.6, ale a¾ - do verze PHP 3.0.8 fungovala ¹patnì. - </para> + <simpara> + Od <literal>PHP 5.0.0</literal> je poèet nalezených a zamìnìných + øetìzcù (<parameter>search</parameter>) vrácen v parametru + <parameter>count</parameter>, který je pøedáván referencí. + Pøed <literal>PHP 5.0.0</literal> není tento parametr k dispozici. + </simpara> </note> <para> - Viz také: <function>ereg_replace</function> a + Viz také + <function>str_ireplace</function>, + <function>substr_replace</function>, + <function>ereg_replace</function>, + <function>preg_replace</function> a <function>strtr</function>. </para> </refsect1> Index: phpdoc-cs/reference/strings/functions/stripslashes.xml diff -u phpdoc-cs/reference/strings/functions/stripslashes.xml:1.1 phpdoc-cs/reference/strings/functions/stripslashes.xml:1.2 --- phpdoc-cs/reference/strings/functions/stripslashes.xml:1.1 Sun Apr 14 19:48:12 2002 +++ phpdoc-cs/reference/strings/functions/stripslashes.xml Fri Jan 2 13:06:11 2004 @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'stripslashes' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.stripslashes"> <refnamediv> <refname>stripslashes</refname> <refpurpose> - Un-quote string quoted with <function>addslashes</function> + Zru¹it escapování provedené funkcí <function>addslashes</function> </refpurpose> </refnamediv> <refsect1> @@ -15,12 +14,37 @@ <methodparam><type>string</type><parameter>str</parameter></methodparam> </methodsynopsis> <para> - Vrací øetìzec bez odstranìných zpìtných lomítek. + Vrací øetìzec s odstranìnými zpìtnými lomítky. (<literal>\'</literal> se stává <literal>'</literal> a pod.) - Zdvojená zpìtná lomítka se spojují do jednoduchých. + Zdvojená zpìtná lomítka (<literal>\\</literal>) se spojují do + jednoduchých (<literal>\</literal>). + </para> + <para> + Funkce <function>stripslashes</function> mù¾e být pou¾ita napøíklad tehdy, kdy¾ je PHP + direktiva <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> + nastavena na <literal>on</literal> (co¾ je výchozí nastavení) a vy + tato data nevkládáte na místa (jako je databáze), která toto escapování potøebují. + To je napøíklad tehdy, kdy¾ data zadaná do HTML formuláøe pouze + vypisujete. + </para> + <para> + <example> + <title>Pøíklad funkce <function>stripslashes</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = "Jmenuje¹ se O\'reilly?"; + +// Outputs: Jmenuje¹ se O'reilly? +echo stripslashes($str); +?> +]]> + </programlisting> + </example> </para> <simpara> - Viz také: <function>addslashes</function>. + Viz také <function>addslashes</function> a + <function>get_magic_quotes_gpc</function>. </simpara> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/stristr.xml diff -u phpdoc-cs/reference/strings/functions/stristr.xml:1.1 phpdoc-cs/reference/strings/functions/stristr.xml:1.2 --- phpdoc-cs/reference/strings/functions/stristr.xml:1.1 Sun Apr 14 19:48:12 2002 +++ phpdoc-cs/reference/strings/functions/stristr.xml Fri Jan 2 13:06:11 2004 @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'stristr' in en/ tree in rev 1.8 --> +<!-- EN-Revision: 1.5 Maintainer: luk Status: ready --> <refentry id="function.stristr"> <refnamediv> <refname>stristr</refname> <refpurpose> - Case-insensitive <function>strstr</function> + <function>strstr</function> bez rozli¹ení velikosti písmen </refpurpose> </refnamediv> <refsect1> @@ -26,12 +25,25 @@ </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. </para> <para> - Viz také: <function>strchr</function>, - <function>strrchr</function>, - <function>substr</function> a + <example> + <title>Pøíklad pou¾ití <function>stristr</function></title> + <programlisting role="php"> +<![CDATA[ +<?php + $email = 'USER@EXAMPLE.com'; + $domain = stristr($email, 'e'); + echo $domain; // ER@EXAMPLE.com +?> +]]> + </programlisting> + </example> + </para> + <para> + Viz také <function>strchr</function>, + <function>strrchr</function>, <function>substr</function> a <function>ereg</function>. </para> </refsect1> Index: phpdoc-cs/reference/strings/functions/strlen.xml diff -u phpdoc-cs/reference/strings/functions/strlen.xml:1.1 phpdoc-cs/reference/strings/functions/strlen.xml:1.2 --- phpdoc-cs/reference/strings/functions/strlen.xml:1.1 Sun Apr 14 19:48:12 2002 +++ phpdoc-cs/reference/strings/functions/strlen.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strlen' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.strlen"> <refnamediv> <refname>strlen</refname> @@ -15,6 +14,25 @@ <para> Vrací délku (poèet znakù) argumentu <parameter>string</parameter>. </para> + <para> + <example> + <title>Pøíklad funkce <function>strlen</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$str = 'abcdef'; +echo strlen($str); // 6 + +$str = ' ab cd '; +echo strlen($str); // 7 +?> +]]> + </programlisting> + </example> + </para> + <para> + Viz také <function>count</function>. + </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/strpos.xml diff -u phpdoc-cs/reference/strings/functions/strpos.xml:1.1 phpdoc-cs/reference/strings/functions/strpos.xml:1.2 --- phpdoc-cs/reference/strings/functions/strpos.xml:1.1 Sun Apr 14 19:48:14 2002 +++ phpdoc-cs/reference/strings/functions/strpos.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strpos' in en/ tree in rev 1.8 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.strpos"> <refnamediv> <refname>strpos</refname> @@ -23,40 +22,48 @@ </para> <para> Pokud <parameter>needle</parameter> nenajde, vrací &false;. - <note> - <para> - Návratové hodnoty "znak nalezen na pozici 0" a "znak nenalezen" se dají - snadno zamìnit. Tady je návod, jak zjistit tento rozdíl: - <informalexample> - <programlisting role="php"> -// v PHP 4.0b3 a novìj¹ích: -$pos = strpos ($mystring, "b"); -if ($pos === false) { // tøi rovnítka - // nenalezeno... -} + </para> + + &return.falseproblem; + + <para> + <example> + <title><function>strpos</function> examples</title> + <programlisting role="php"> +<![CDATA[ +<?php +$mystring = 'abc'; +$findme = 'a'; +$pos = strpos($mystring, $findme); -// ve verzích star¹ích ne¾ 4.0b3: -$pos = strpos ($mystring, "b"); -if (is_string ($pos) && !$pos) { - // nenalezeno... +// V¹imnìte si pou¾ití ===. Obyèejné == by nefungovalo podle pøedpokladu, +// proto¾e 'a' je na nultém (prvním) místì. +if ($pos === false) { + echo "Øetìzec '$findme' nebyl nalezen v øetìzci '$mystring'"; +} else { + echo "Øetìzec '$findme' nebyl nalezen v øetìzci '$mystring'"; + echo " a je na pozici $pos"; } - </programlisting> - </informalexample> - </para> - </note> + +?> +]]> + </programlisting> + </example> </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. </para> <para> - Volitelný argument <parameter>offset</parameter> vám umo¾òuje urèit na + Volitelný argument <parameter>offset</parameter> vám umo¾òuje urèit, na které pozici v <parameter>haystack</parameter> má hledání zaèít. Vrácená pozice je i tak relativní k zaèátku <parameter>haystack</parameter>. </para> <para> Viz také: <function>strrpos</function>, - <function>strrchr</function>, + <function>stripos</function>, + <function>strripos</function>, + <function>strrchr</function>, <function>substr</function>, <function>stristr</function> a <function>strstr</function>. Index: phpdoc-cs/reference/strings/functions/strrchr.xml diff -u phpdoc-cs/reference/strings/functions/strrchr.xml:1.1 phpdoc-cs/reference/strings/functions/strrchr.xml:1.2 --- phpdoc-cs/reference/strings/functions/strrchr.xml:1.1 Sun Apr 14 19:48:14 2002 +++ phpdoc-cs/reference/strings/functions/strrchr.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strrchr' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.strrchr"> <refnamediv> <refname>strrchr</refname> @@ -15,7 +14,7 @@ </methodsynopsis> <para> Tato funkce vrací tu èást <parameter>haystack</parameter>, která zaèíná - poslením výskytem <parameter>needle</parameter> a pokraèuje do konce + posledním výskytem <parameter>needle</parameter> a pokraèuje do konce <parameter>haystack</parameter>. </para> <para> @@ -23,27 +22,31 @@ </para> <para> Pokud <parameter>needle</parameter> obsahuje více ne¾ jeden znak, pou¾ije - se první z nich. + se první z nich. Toto chování je odli¹né od funkce + <function>strchr</function>. </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. <example> <title>Ukázka <function>strrchr</function></title> <programlisting role="php"> +<![CDATA[ +<?php // získat poslední adresáø v $PATH -$dir = substr (strrchr ($PATH, ":"), 1); +$dir = substr(strrchr($PATH, ":"), 1); // získat v¹echno po posledním konci øádku $text = "Øádek 1\nØádek 2\nØádek 3"; -$last = substr (strrchr ($text, 10), 1 ); +$last = substr(strrchr($text, 10), 1 ); +?> +]]> </programlisting> </example> </para> <para> - Viz také: <function>substr</function>, - <function>stristr</function> a - <function>strstr</function>. + Viz také <function>strchr</function>, <function>substr</function>, + <function>stristr</function> a <function>strstr</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/strrpos.xml diff -u phpdoc-cs/reference/strings/functions/strrpos.xml:1.1 phpdoc-cs/reference/strings/functions/strrpos.xml:1.2 --- phpdoc-cs/reference/strings/functions/strrpos.xml:1.1 Sun Apr 14 19:48:14 2002 +++ phpdoc-cs/reference/strings/functions/strrpos.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strrpos' in en/ tree in rev 1.8 --> +<!-- EN-Revision: 1.9 Maintainer: luk Status: ready --> <refentry id="function.strrpos"> <refnamediv> <refname>strrpos</refname> @@ -12,11 +11,12 @@ <type>int</type><methodname>strrpos</methodname> <methodparam><type>string</type><parameter>haystack</parameter></methodparam> <methodparam><type>char</type><parameter>needle</parameter></methodparam> + <methodparam choice="opt"><type>int</type><parameter>offset</parameter></methodparam> </methodsynopsis> <para> Vrací èíselnou pozici posledního výskytu <parameter>needle</parameter> v - øetìzci <parameter>haystack</parameter>. <parameter>needle</parameter> mù¾e - být jen jeden znak dlouhá. Pokud obsahuje více znakù, pou¾ije se první z + øetìzci <parameter>haystack</parameter>. Øetìzec <parameter>needle</parameter> mù¾e + být v PHP 4 jen jeden znak dlouhý. Pokud obsahuje více znakù, pou¾ije se první z nich. </para> <para> @@ -27,17 +27,22 @@ snadno zamìnit. Tady je návod, jak zjistit tento rozdíl: <informalexample> <programlisting role="php"> +<![CDATA[ +<?php + // v PHP 4.0b3 a novìj¹ích: -$pos = strpos ($mystring, "b"); -if ($pos === false) { // tøi rovnítka +$pos = strrpos($mystring, "b"); +if ($pos === false) { // v¹imnìte si: tøi rovnítka // nenalezeno... } // ve verzích star¹ích ne¾ 4.0b3: -$pos = strpos ($mystring, "b"); -if (is_string ($pos) && !$pos) { +$pos = strrpos($mystring, "b"); +if (is_bool($pos) && !$pos) { // nenalezeno... } +?> +]]> </programlisting> </informalexample> </para> @@ -45,11 +50,26 @@ </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. </para> + <note> + <simpara> + Od <literal>PHP 5.0.0</literal> mù¾e být zadán parametr <parameter>offset</parameter>. + To zpùsobí, ¾e hledání zaène od urèité pozice v + øetìzci. Záporné hodnoty zastaví hledání na urèitém místì + pøed koncem øetìzce. + </simpara> + </note> + <note> + <simpara> + Parametr <parameter>needle</parameter> mù¾e být od <literal>PHP 5.0.0</literal> + øetìzec del¹í ne¾ 1 znak. + </simpara> + </note> <para> - Viz také: <function>strpos</function>, - <function>strrchr</function>, + Viz také <function>strpos</function>, + <function>strripos</function>, + <function>strrchr</function>, <function>substr</function>, <function>stristr</function> a <function>strstr</function>. Index: phpdoc-cs/reference/strings/functions/strstr.xml diff -u phpdoc-cs/reference/strings/functions/strstr.xml:1.1 phpdoc-cs/reference/strings/functions/strstr.xml:1.2 --- phpdoc-cs/reference/strings/functions/strstr.xml:1.1 Sun Apr 14 19:48:14 2002 +++ phpdoc-cs/reference/strings/functions/strstr.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strstr' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.6 Maintainer: luk Status: ready --> <refentry id="function.strstr"> <refnamediv> <refname>strstr</refname> @@ -22,12 +21,12 @@ </para> <para> Pokud <parameter>needle</parameter> není øetìzec, pøevede se na integer a - pou¾ije se jako XXX ordinal hodnota znaku. + pou¾ije se jako èíselná hodnota znaku. </para> <para> <note> <para> - Pozn.: tato funkce je case-sensitive. Pro case-insensitive hledání + Pozn.: tato funkce rozli¹uje velikost písmen. Pro hledání bez rozli¹ení velikosti písmen pou¾ijte <function>stristr</function>. </para> </note> @@ -36,17 +35,30 @@ <example> <title>Ukázka <function>strstr</function></title> <programlisting role="php"> -$email = 'sterling@designmultimedia.com'; -$domain = strstr ($email, '@'); -print $domain; // vytiskne @designmultimedia.com +<![CDATA[ +<?php +$email = 'user@example.com'; +$domain = strstr($email, '@'); +echo $domain; // @example.com +?> +]]> </programlisting> </example> </para> <para> - Viz také: <function>stristr</function>, - <function>strrchr</function>, - <function>substr</function> a - <function>ereg</function>. + <note> + <para> + Pokud pouze chcete zjistit, zda se urèitý øetìzec <parameter>needle</parameter> + vyskytuje v øetìzci <parameter>haystack</parameter>, je rychlej¹í a ménì nároèné + na pamì» pou¾ití funkce <function>strpos</function>. + </para> + </note> + </para> + <para> + Viz také <function>ereg</function>, <function>preg_match</function>, + <function>strchr</function>, <function>stristr</function>, + <function>strpos</function>, <function>strrchr</function> a + <function>substr</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/strtr.xml diff -u phpdoc-cs/reference/strings/functions/strtr.xml:1.1 phpdoc-cs/reference/strings/functions/strtr.xml:1.2 --- phpdoc-cs/reference/strings/functions/strtr.xml:1.1 Sun Apr 14 19:48:16 2002 +++ phpdoc-cs/reference/strings/functions/strtr.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'strtr' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.4 Maintainer: luk Status: ready --> <refentry id="function.strtr"> <refnamediv> <refname>strtr</refname> @@ -14,6 +13,11 @@ <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> Tato funkce upraví <parameter>str</parameter> tak, ¾e v¹echny výskyty v¹ech znakù ve <parameter>from</parameter> pøelo¾í na odpovídající znaky v @@ -25,7 +29,11 @@ <example> <title>Ukázka <function>strtr</function></title> <programlisting role="php"> +<![CDATA[ +<?php $addr = strtr($addr, "äåö", "aao"); +?> +]]> </programlisting> </example> </para> @@ -33,19 +41,28 @@ <function>strtr</function> se dá také volat pouze se dvìma argumenty. Pøi volání se dvìma argumenty se chová takto: <parameter>from</parameter> musí být pole obsahující páry øetìzcù, které se zamìní ve zdrojovém øetìzci. - <function>strtr</function> v¾dy hledá nejdel¹í mo¾nou shodu a *NENAHRAZUJE* + <function>strtr</function> v¾dy hledá nejdel¹í mo¾nou shodu a NENAHRAZUJE ty èásti øetìzce, na kterých u¾ pracovala. </para> - <para> - Ukázky: - <informalexample> + <example> + <title><function>strtr</function> example with two arguments</title> <programlisting role="php"> -$trans = array ("ahoj" => "nazdar", "nazdar" => "ahoj"); -echo strtr("nazdar lidi, øekl jsem ahoj", $trans) . "\n"; +<![CDATA[ +<?php +$trans = array("ahoj" => "nazdar", "nazdar" => "ahoj"); +echo strtr("nazdar lidi, øekl jsem ahoj", $trans); +?> +]]> </programlisting> - </informalexample> - Výsledek: "ahoj lidi, øekl jsem nazdar", + <para> + Výsledek: </para> + <screen> +<![CDATA[ +ahoj lidi, øekl jsem nazdar +]]> + </screen> + </example> <note> <simpara> Tato vlastnost (dva argumenty) byla pøidána v PHP 4.0. Index: phpdoc-cs/reference/strings/functions/substr.xml diff -u phpdoc-cs/reference/strings/functions/substr.xml:1.1 phpdoc-cs/reference/strings/functions/substr.xml:1.2 --- phpdoc-cs/reference/strings/functions/substr.xml:1.1 Sun Apr 14 19:48:16 2002 +++ phpdoc-cs/reference/strings/functions/substr.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'substr' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.7 Maintainer: luk Status: ready --> <refentry id="function.substr"> <refnamediv> <refname>substr</refname> @@ -19,61 +18,79 @@ urèenou argumenty <parameter>start</parameter> a <parameter>length</parameter>. </para> <para> - Pokud je <parameter>start</parameter> pozitivní, vrácený øetìzec zaène + Pokud je <parameter>start</parameter> kladný, vrácený øetìzec zaène <parameter>start</parameter>-tým znakem øetìzce <parameter>string</parameter>, poèítáno od nuly. Napøíklad v øetìzci '<literal>abcdef</literal>' je znakem na <literal>0</literal>-té pozici '<literal>a</literal>', znakem na pozici <literal>2</literal> je '<literal>c</literal>', atd. </para> + <example> + <title>Základní pou¾ití <function>substr</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$rest = substr("abcdef", 1); // vrátí "bcdef" +$rest = substr("abcdef", 1, 3); // vrátí "bcd" +$rest = substr("abcdef", 0, 4); // vrátí "abcd" +$rest = substr("abcdef", 0, 8); // vrátí "abcdef" + +// Pøístup pøes slo¾ené závorky je dal¹í mo¾nost +$string = 'abcdef'; +echo $string{0}; // vrátí a +echo $string{3}; // vrátí d +?> +]]> + </programlisting> + </example> <para> - Pøíklady: - <informalexample> - <programlisting role="php"> -$rest = substr ("abcdef", 1); // vrátí "bcdef" -$rest = substr ("abcdef", 1, 3); // vrátí "bcd" - </programlisting> - </informalexample> - </para> - <para> - Pokud je <parameter>start</parameter> negativní, vrácený øetìzec zaène + Pokud je <parameter>start</parameter> záporný, vrácený øetìzec zaène <parameter>start</parameter>-tým znakem od konce argumentu <parameter>string</parameter>. </para> - <para> - Pøíklady: - <informalexample> - <programlisting role="php"> -$rest = substr ("abcdef", -1); // vrátí "f" -$rest = substr ("abcdef", -2); // vrátí "ef" -$rest = substr ("abcdef", -3, 1); // vrátí "d" - </programlisting> - </informalexample> - </para> + <example> + <title>Pou¾ití záporného èísla v parametru <parameter>start</parameter></title> + <programlisting role="php"> +<![CDATA[ +<?php +$rest = substr("abcdef", -1); // returns "f" +$rest = substr("abcdef", -2); // returns "ef" +$rest = substr("abcdef", -3, 1); // returns "d" +?> +]]> + </programlisting> + </example> <para> Pokud je argument <parameter>length</parameter> kladný, vrácený øetìzec - skonèí <parameter>length</parameter> znakù od <parameter>start</parameter>. - Pokud by to znamenalo øetìzec se zápornou délkou (<parameter>start</parameter> - je za <parameter>length</parameter>), vrácený øetìzec bude sestávat z - jediného znaku na pozici <parameter>start</parameter>. - </para> - <para> - Pokud je argument <parameter>length</parameter> kladný, vrácený øetìzec - skonèí <parameter>length</parameter> znakù od konce argumentu - <parameter>string</parameter>. Pokud by to znamenalo øetìzec se zápornou - délkou, vrácený øetìzec bude sestávat z jediného znaku na pozici - <parameter>start</parameter>. - </para> - <para> - Pøíklady: - <informalexample> - <programlisting role="php"> -$rest = substr ("abcdef", 1, -1); // vrátí "bcde" - </programlisting> - </informalexample> - </para> - <para> - Viz také: <function>strrchr</function> a - <function>ereg</function>. + skonèí <parameter>length</parameter> znakù za pozicí <parameter>start</parameter>. + Pokud je parametr <parameter>string</parameter> krat¹í + ne¾ <parameter>start</parameter> znakù, vrátí tato funkce + &false;. + </para> + <para> + Pokud je parametr <parameter>length</parameter> negativní, tak bude + z konce øetìzce <parameter>string</parameter> vynechán odpovídající poèet znakù. + Pokud parametr + <parameter>start</parameter> urèuje pozici za tímto zkrácením, + bude vrácen prázdný øetìzec. + </para> + <example> + <title>Pou¾ití záporného parametru <parameter>length</parameter></title> + <programlisting role="php"> +<![CDATA[ +<?php +$rest = substr("abcdef", 0, -1); // vrátí "abcde" +$rest = substr("abcdef", 2, -1); // vrátí "cde" +$rest = substr("abcdef", 4, -4); // vrátí "" +$rest = substr("abcdef", -3, -1); // vrátí "de" +?> +]]> + </programlisting> + </example> + <para> + Viz také <function>strrchr</function>, + <function>substr_replace</function>, + <function>ereg</function> a + <function>trim</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/strings/functions/trim.xml diff -u phpdoc-cs/reference/strings/functions/trim.xml:1.1 phpdoc-cs/reference/strings/functions/trim.xml:1.2 --- phpdoc-cs/reference/strings/functions/trim.xml:1.1 Sun Apr 14 19:48:16 2002 +++ phpdoc-cs/reference/strings/functions/trim.xml Fri Jan 2 13:06:11 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/strings.xml, last change in rev 1.1 --> -<!-- last change to 'trim' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.trim"> <refnamediv> <refname>trim</refname> @@ -13,15 +12,88 @@ <methodsynopsis> <type>string</type><methodname>trim</methodname> <methodparam><type>string</type><parameter>str</parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>charlist</parameter></methodparam> </methodsynopsis> + <note> + <simpara> + Volitelný parametr <parameter>charlist</parameter> byl pøidán + v PHP 4.1.0 + </simpara> + </note> <para> - Tato funkce odstraòuje netisknutelné znaky ze zaèátku a konce øetìzce a - vrací øetìzec bez tìchto znakù. Netisknutelné znaky, které se v souèasnosti - odstraòují, jsou: "\n", "\r", "\t", "\v", "\0", a mezera. + Tato funkce odstraòuje bílé znaky ze zaèátku a konce øetìzce a + vrací øetìzec bez tìchto znakù. + Bez druhého parametru + odstraní tato funkce následující znaky: + <!-- sorted by importance. Printed 3 times: trim, ltrim, rtrim --> + <itemizedlist> + <listitem> + <simpara> + " " (<acronym>ASCII</acronym> <literal>32</literal> + (<literal>0x20</literal>)), obyèejná mezera. + </simpara> + </listitem> + <listitem> + <simpara> + "\t" (<acronym>ASCII</acronym> <literal>9</literal> + (<literal>0x09</literal>)), tabulátor. + </simpara> + </listitem> + <listitem> + <simpara> + "\n" (<acronym>ASCII</acronym> <literal>10</literal> + (<literal>0x0A</literal>)), nová øádka (line feed). + </simpara> + </listitem> + <listitem> + <simpara> + "\r" (<acronym>ASCII</acronym> <literal>13</literal> + (<literal>0x0D</literal>)), návrat vozíku (carriage return). + </simpara> + </listitem> + <listitem> + <simpara> + "\0" (<acronym>ASCII</acronym> <literal>0</literal> + (<literal>0x00</literal>)), znak <literal>NUL</literal>. + </simpara> + </listitem> + <listitem> + <simpara> <!-- not \v, since not supported by PHP --> + "\x0B" (<acronym>ASCII</acronym> <literal>11</literal> + (<literal>0x0B</literal>)), vertikální tabulátor. + </simpara> + </listitem> + </itemizedlist> </para> <para> - Viz také <function>chop</function>, <function>rtrim</function> a - <function>ltrim</function>. + Mù¾ete také urèit, které znaky chcete odstranit, a to pomocí + parametru <parameter>charlist</parameter>. + Jednodu¹e vyjmenujte v¹echny znaky, které chcete odstranit. Pomocí + <literal>..</literal> mù¾ete urèit rozsah znakù. + </para> + <example> + <title>Pøíklady pou¾ití <function>trim</function></title> + <para> + <programlisting role="php"> +<![CDATA[ +<?php + +$text = "\t\tZde je pár slov :) ... "; +$trimmed = trim($text); +// $trimmed = "Zde je pár slov :) ..." +$trimmed = trim($text, " \t."); +// $trimmed = "Zde je pár slov :)" +$clean = trim($binary, "\0x00..\0x1F"); +// odstranit kontrolní znaky ASCII ze zaèátku i konce promìnné $binary +// (od 0 do 31 vèetnì) + +?> +]]> + </programlisting> + </para> + </example> + <para> + Viz také <function>ltrim</function> a <function>rtrim</function>. </para> </refsect1> </refentry> Index: phpdoc-cs/reference/url/functions/rawurlencode.xml diff -u phpdoc-cs/reference/url/functions/rawurlencode.xml:1.1 phpdoc-cs/reference/url/functions/rawurlencode.xml:1.2 --- phpdoc-cs/reference/url/functions/rawurlencode.xml:1.1 Sun Apr 14 19:48:24 2002 +++ phpdoc-cs/reference/url/functions/rawurlencode.xml Fri Jan 2 13:06:12 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/url.xml, last change in rev 1.1 --> -<!-- last change to 'rawurlencode' in en/ tree in rev 1.6 --> +<!-- EN-Revision: 1.7 Maintainer: luk Status: ready --> <refentry id="function.rawurlencode"> <refnamediv> <refname>rawurlencode</refname> @@ -23,23 +22,32 @@ <example> <title>Pøíklad <function>rawurlencode</function> è. 1</title> <programlisting role="php"> -echo '<A HREF="ftp://user:', rawurlencode ('foo @+%/'), - '@ftp.my.com/x.txt">'; +<![CDATA[ +<?php +echo '<a href="ftp://user:', rawurlencode('foo @+%/'), + '@ftp.example.com/x.txt">'; +?> +]]> </programlisting> </example> - Nebo, pokud pøedáváte informace v komponentì URL obsahující info o cestì: + Nebo, pokud pøedáváte informace v komponentì URL obsahující informaci o cestì: <example> <title>Pøíklad <function>rawurlencode</function> è. 2</title> <programlisting role="php"> -echo '<A HREF="http://x.com/department_list_script/', - rawurlencode ('sales and marketing/Miami'), '">'; +<![CDATA[ +<?php +echo '<a href="http://example.com/department_list_script/', + rawurlencode('sales and marketing/Miami'), '">'; +?> +]]> </programlisting> </example> </para> <simpara> Viz také: <function>rawurldecode</function>, <function>urldecode</function>, - <function>urlencode</function>. + <function>urlencode</function> a + <ulink url="&url.rfc;1738">RFC 1738</ulink>. </simpara> </refsect1> </refentry> Index: phpdoc-cs/reference/url/functions/urldecode.xml diff -u phpdoc-cs/reference/url/functions/urldecode.xml:1.1 phpdoc-cs/reference/url/functions/urldecode.xml:1.2 --- phpdoc-cs/reference/url/functions/urldecode.xml:1.1 Sun Apr 14 19:48:24 2002 +++ phpdoc-cs/reference/url/functions/urldecode.xml Fri Jan 2 13:06:12 2004 @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="iso-8859-2"?> -<!-- splitted from ./cs/functions/url.xml, last change in rev 1.1 --> -<!-- last change to 'urldecode' in en/ tree in rev 1.2 --> +<!-- EN-Revision: 1.3 Maintainer: luk Status: ready --> <refentry id="function.urldecode"> <refnamediv> <refname>urldecode</refname> @@ -18,20 +17,24 @@ <example> <title>Pøíklad <function>urldecode</function></title> <programlisting role="php"> -$a = split ('&', $querystring); +<![CDATA[ +<?php +$a = explode('&', $QUERY_STRING); $i = 0; -while ($i < count ($a)) { - $b = split ('=', $a [$i]); - echo 'Hodnota argumentu ', htmlspecialchars (urldecode ($b [0])), - ' je ', htmlspecialchars (urldecode ($b [1])), "<BR>"; +while ($i < count($a)) { + $b = split('=', $a[$i]); + echo 'Hodnota parametru ', htmlspecialchars(urldecode($b[0])), + ' je ', htmlspecialchars(urldecode($b[1])), "<br />\n"; $i++; } +?> +]]> </programlisting> </example> </para> <para> Viz také <function>urlencode</function>, - <function>rawurlencode</function>, + <function>rawurlencode</function> a <function>rawurldecode</function>. </para> </refsect1>