luk Sun Mar 17 17:16:10 2002 EDT
Added files:
/phpdoc/cs/language functions.xml
Modified files:
/phpdoc/cs translation.xml
/phpdoc/cs/language references.xml
Log:
Index: phpdoc/cs/translation.xml
diff -u phpdoc/cs/translation.xml:1.3 phpdoc/cs/translation.xml:1.4
--- phpdoc/cs/translation.xml:1.3 Thu Mar 14 18:17:32 2002
+++ phpdoc/cs/translation.xml Sun Mar 17 17:16:09 2002
@@ -14,18 +14,16 @@
</translators>
<work-in-progress>
- <file name="appendices/phpdevel.xml" person="luk" type="translation" />
- <file name="appendices/predefined.xml" person="luk" type="translation" />
- <file name="appendices/resources.xml" person="luk" type="translation" />
- <file name="functions/mysql.xml" person="costra" type="translation" />
- <file name="language/control-structures.xml person="luk" type="translation" />
- <file name="language/expressions.xml person="luk" type="translation" />
- <file name="language/functions.xml person="luk" type="translation" />
- <file name="language/operators.xml person="luk" type="translation" />
- <file name="language/oop.xml person="luk" type="translation" />
- <file name="language/references.xml person="luk" type="translation" />
- <file name="language/types.xml person="luk" type="translation" />
- <file name="language/variables.xml person="luk" type="translation" />
+ <file name="appendices/phpdevel.xml" person="luk" type="translation" />
+ <file name="appendices/predefined.xml" person="luk" type="translation" />
+ <file name="appendices/resources.xml" person="luk" type="translation" />
+ <file name="functions/mysql.xml" person="costra" type="translation"
+/>
+ <file name="language/control-structures.xml" person="luk" type="translation" />
+ <file name="language/expressions.xml" person="luk" type="translation" />
+ <file name="language/operators.xml" person="luk" type="translation" />
+ <file name="language/oop.xml" person="luk" type="translation" />
+ <file name="language/types.xml" person="luk" type="translation" />
+ <file name="language/variables.xml" person="luk" type="translation" />
</work-in-progress>
</translation>
Index: phpdoc/cs/language/references.xml
diff -u phpdoc/cs/language/references.xml:1.1 phpdoc/cs/language/references.xml:1.2
--- phpdoc/cs/language/references.xml:1.1 Thu Mar 14 18:17:33 2002
+++ phpdoc/cs/language/references.xml Sun Mar 17 17:16:09 2002
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="iso-8859-2"?>
-<!-- EN-Revision: 1.22 Maintainer: luk Status: mixed -->
+<!-- EN-Revision: 1.22 Maintainer: luk Status: ready -->
<chapter id="language.references">
<title>Vysv�tlen� referenc� (odkaz�)</title>
<sect1 id="language.references.whatare">
<title>Co jsou reference</title>
- <simpara>
- References are a means in PHP to access the same variable content
- by different names. They are not like C pointers, they are symbol
- table aliases. Note that in PHP, variable name and variable content
- are different, so the same content can have different names.
- The most close analogy is with Unix filenames and files -
- variable names are directory entries, while variable contents is
- the file itself. References can be thought of as hardlinking in
- Unix filesystem.
+ <simpara>
+ Reference (odkazy) jsou prost�edek, ja v PHP p�istupovat k t�mu� obsahu
+ prom�nn� pod r�zn�mi jm�ny. Nejsou to ukazatele (pointery jako v C, jsou
+ to aliasy v tabulce symbol�. Uv�domte si, �e v PHP je rozd�l mezi
+ n�zvem prom�nn� a jej�m obsahem, tak�e stejn� obsah m��e m�t r�zn� n�zvy.
+ Nejbli��� analogi� jsou n�zvy soubor� a soubory v UNIXu - n�zvy
+ prom�nn�ch jsou polo�ky adres��e, obsahy prom�nn�ch samotn� soubory.
+ Na reference m��e b�t naz�r�no jako na hardlinky v UNIXov�m syst�mu
+ soubor�.
</simpara>
</sect1>
<sect1 id="language.references.whatdo">
- <title>What References Do</title>
+ <title>Co reference d�laj�</title>
<para>
- PHP references allow you to make two variables to refer to the
- same content. Meaning, when you do:
+ PHP reference umo��uj� zajistit, aby dv� prom�nn� odkazovaly na tent��
+ obsah. Tzn. kdy� provedete:
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -30,21 +30,20 @@
]]>
</programlisting>
</informalexample>
- it means that <varname>$a</varname> and <varname>$b</varname>
- point to the same variable.
+ znamen� to, �e <varname>$a</varname> a <varname>$b</varname> ukazuj�
+ na stejnou prom�nnou.
<note>
<para>
- <varname>$a</varname> and <varname>$b</varname> are completely
- equal here, that's not <varname>$a</varname> is pointing to
- <varname>$b</varname> or vice versa, that's
- <varname>$a</varname> and <varname>$b</varname> pointing to the
- same place.
+ <varname>$a</varname> a <varname>$b</varname> jsou zde �pln�
+ ekvivalentn�, tj. nikoliv �e <varname>$a</varname> ukazuje na
+ <varname>$b</varname> apod., n�br� �e <varname>$a</varname>
+ a <varname>$b</varname> ukazuj� na stejn� m�sto.
</para>
</note>
</para>
<para>
- The same syntax can be used with functions, that return references,
- and with <literal>new</literal> operator (in PHP 4.0.4 and later):
+ Stejn� syntaxe se m��e pou��t s funkcemi, kter� vrac� reference a
+ s oper�torem <literal>new</literal> (v PHP 4.0.4 a pozd�j��ch):
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -56,19 +55,19 @@
</para>
<note>
<para>
- Not using the <literal>&</literal> operator causes a copy of the
- object to be made. If you use <literal>$this</literal> in the class it
- will operate on the current instance of the class. The assignment without
- <literal>&</literal> will copy the instance (i.e. the object) and
- <literal>$this</literal> will operate on the copy, which is not always
- what is desired. Usually you want to have a single instance to work with,
- due to performance and memory consumption issues.
+ Nepou�it� oper�toru <literal>&</literal> zp�sob� zkop�rov�n�
+ objektu. Kdy� ve t��d� pou�ijete <literal>$this</literal>, bude se
+ pracovat s aktu�ln� instanc� t��dy. P�i�azen� bez
+ <literal>&</literal> zkop�ruje instanci (nap�. objektu) a
+ <literal>$this</literal> bude pracovat s touto kopi�, co� nen� v�dy to,
+ co se po�aduje. V�t�inou chcete m�t jedinou instanci, s n�� budete
+ pracovat, kv�li rychlosti a alokaci pam�ti.
</para>
</note>
<para>
- The second thing references do is to pass variables
- by-reference. This is done by making a local variable in a function and
- a variable in the calling scope reference to the same content. Example:
+ Druhou v�c�, kterou reference d�laj�, je p�ed�v�n� prom�nn�ch odkazem.
+ To se d�l� vytvo�en�m lok�ln� prom�nn� ve funkci a prom�nn� v kontextu
+ volaj�c�ho prost�ed�, kdy se odkazuje na tent�� obsah. Nap��klad:
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -82,23 +81,22 @@
]]>
</programlisting>
</informalexample>
- will make <varname>$a</varname> to be 6. This happens because in
- the function <varname>foo</varname> the variable
- <varname>$var</varname> refers to the same content as
- <varname>$a</varname>. See also more detailed explanations about <link
- linkend="language.references.pass">passing by reference</link>.
+ nastav� do <varname>$a</varname> hodnotu 6. To proto, �e ve funkci
+ <varname>foo</varname> prom�nn� <varname>$var</varname> odkazuje tent��
+ obsah jako <varname>$a</varname>. Viz detailn�j�� vysv�tlen� o
+ <link linkend="language.references.pass">p�ed�v�n� odkazem</link>.
</para>
<simpara>
- The third thing reference can do is <link
- linkend="language.references.return">return by reference</link>.
+ T�et� v�c�, kterou mohou reference d�lat, je
+ <link linkend="language.references.return">vracen� p�es reference</link>.
</simpara>
</sect1>
<sect1 id="language.references.arent">
- <title>What References Are Not</title>
+ <title>Co reference nejsou</title>
<para>
- As said before, references aren't pointers. That means, the
- following construct won't do what you expect:
+ Jak ji� bylo �e�eno, reference nejsou ukazatele. To znamen�, �e tento
+ konstrukt nebude d�lat to, co o�ek�v�te:
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -112,24 +110,22 @@
</informalexample>
</para>
<simpara>
- What happens is that <varname>$var</varname> in
- <varname>foo</varname> will be bound with
- <varname>$bar</varname> in caller, but then it will be
- re-bound with <varname>$GLOBALS["baz"]</varname>. There's no way
- to bind <varname>$bar</varname> in the calling scope to something else
- using the reference mechanism, since <varname>$bar</varname> is not
- available in the function <varname>foo</varname> (it is represented by
- <varname>$var</varname>, but <varname>$var</varname> has only
- variable contents and not name-to-value binding in the calling
- symbol table).
+ Nastane to, �e <varname>$var</varname> ve funkci <varname>foo</varname>
+ bude p�i�azena <varname>$bar</varname> ve volaj�c�m kontextu, av�ak pot�
+ bude p�i�azena <varname>$GLOBALS["baz"]</varname>. Nen� zp�sob, jak
+ p�i�adit <varname>$bar</varname> ve volaj�c�m kontextu n��emu jin�mu
+ za pou�it� mechanismu referenc�, proto�e <varname>$bar</varname> nen�
+ ve funkci <varname>foo</varname> dostupn� (je reprezentov�na
+ <varname>$var</varname>, ale <varname>$var</varname> m� pouze obsah
+ a nikoli spojen� n�zvu s hodnotou v tabulce symbol�).
</simpara>
</sect1>
<sect1 id="language.references.pass">
- <title>Passing by Reference</title>
+ <title>P�ed�v�n� referenc� (odkazem)</title>
<para>
- You can pass variable to function by reference, so that function could modify
- its arguments. The syntax is as follows:
+ M��ete p�ed�vat prom�nnou do funkce pomoc� odkazu, tak�e funkce m��e
+ modifikovat jej� argumenty. Syntaxe je n�sleduj�c�:
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -140,30 +136,30 @@
$a=5;
foo ($a);
-// $a is 6 here
+// $a je te� 6
]]>
</programlisting>
</informalexample>
- Note that there's no reference sign on function call - only on
- function definition. Function definition alone is enough to
- correctly pass the argument by reference.
+ V�imn�te si, �e ve vol�n� funkce nen� znak reference - pouze v jej�
+ definici. Samotn� definice funkce sta�� na spr�vn� p�ed�v�n� argumentu
+ odkazem.
</para>
<para>
- Following things can be passed by reference:
+ N�sleduj�c� v�ci lze p�ed�vat referenc�:
<itemizedlist>
<listitem>
<simpara>
- Variable, i.e. <literal>foo($a)</literal>
+ Prom�nn�, nap�. <literal>foo($a)</literal>
</simpara>
</listitem>
<listitem>
<simpara>
- New statement, i.e. <literal>foo(new foobar())</literal>
+ Konstrukt s new, nap�. <literal>foo(new foobar())</literal>
</simpara>
</listitem>
<listitem>
<para>
- Reference, returned from a function, i.e.:
+ Reference, vracen� z funkce, nap�.:
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -176,47 +172,46 @@
]]>
</programlisting>
</informalexample>
- See also explanations about <link
- linkend="language.references.return">returning by reference</link>.
+ Viz tak� vysv�tlen�
+ <link linkend="language.references.return">vracen� p�es reference</link>.
</para>
</listitem>
</itemizedlist>
</para>
<para>
- Any other expression should not be passed by reference, as the
- result is undefined. For example, the following examples of passing
- by reference are invalid:
+ ��dn� jin� v�razy nemohou b�t p�ed�v�ny odkazem, v�sledek tohoto nen�
+ definov�n. Nap��klad, n�sleduj�c� uk�zky p�ed�v�n� odkazem jsou neplatn�:
<informalexample>
<programlisting role="php">
<![CDATA[
-function bar() // Note the missing &
+function bar() // V�imn�te si chyb�j�c�ho &
{
$a = 5;
return $a;
}
foo(bar());
-foo($a = 5) // Expression, not variable
-foo(5) // Constant, not variable
+foo($a = 5) // V�raz, nikoli prom�nn�
+foo(5) // Konstanta, nikoli prom�nn�
]]>
</programlisting>
</informalexample>
- These requirements are for PHP 4.0.4 and later.
+ Tyto po�adavky plat� pro PHP 4.0.4 a pozd�j��.
</para>
</sect1>
<sect1 id="language.references.return">
- <title>Returning References</title>
+ <title>Vracen� referenc�</title>
<para>
- Returning by-reference is useful when you want to use a function
- to find which variable a reference should be bound to. When
- returning references, use this syntax:
+ Vracen� odkazem je u�ite�n�, kdy� chcete pou��t funkci k nalezen�
+ prom�nn�, kter� by m�la b�t odkazu p�i�azena. P�i vracen� referenc�
+ pou�ijte tuto syntaxi:
<informalexample>
<programlisting role="php">
<![CDATA[
function &find_var ($param)
{
- ...code...
+ ...n�jak� k�d...
return $found_var;
}
@@ -225,27 +220,25 @@
]]>
</programlisting>
</informalexample>
- In this example, the property of the object returned by the
- <varname>find_var</varname> function would be set, not the
- copy, as it would be without using reference syntax.
+ V tomto p��kladu by bylo funkc� <varname>find_var</varname> nastaveno
+ vlastnictv� t�ho� objektu, nikoli jeho kopie, jak by se stalo bez pou�it�
+ syntaxe bez odkaz�.
</para>
<note>
<simpara>
- Unlike parameter passing, here you have to use
- <literal>&</literal> in both places - to indicate that you
- return by-reference, not a copy as usual, and to indicate that
- reference binding, rather than usual assignment, should be done
- for <varname>$foo</varname>.
+ Narozd�l od p�ed�v�n� parametru, zde mus�te <literal>&</literal>
+ pou��t na obou m�stech - k indikaci, �e vrac�te odkaz a nikoli kopii
+ jako obvykle, a k indikaci p�i�azen� reference do <varname>$foo</varname>
+ nam�sto b�n�ho p�i�azen� (hodnoty).
</simpara>
</note>
</sect1>
<sect1 id="language.references.unset">
- <title>Unsetting References</title>
+ <title>Odnastaven� odkaz�</title>
<para>
- When you unset the reference, you just break the binding between
- variable name and variable content. This does not mean that
- variable content will be destroyed. For example:
+ Kdy� odnastav�te referenci, p�eru��te vazbu mezi n�zvem prom�nn� a jej�m
+ obsahem. To neznamen�, �e by obsah byl zni�en. Nap��klad:
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -255,30 +248,30 @@
]]>
</programlisting>
</informalexample>
- won't unset <varname>$b</varname>, just <varname>$a</varname>.
+ neodnastav� <varname>$b</varname>, n�br� pouze <varname>$a</varname>.
</para>
<simpara>
- Again, it might be useful to think about this as analogous to Unix
- <command>unlink</command> call.
+ Znovu je dobr� si p�ipomenout analogii s UNIXov�m p��kazem
+ <command>unlink</command>.
</simpara>
</sect1>
<sect1 id="language.references.spot">
- <title>Spotting References</title>
+ <title>Dal�� v�skyt referenc�</title>
<simpara>
- Many syntax constructs in PHP are implemented via referencing
- mechanisms, so everything told above about reference binding also
- apply to these constructs. Some constructs, like passing and
- returning by-reference, are mentioned above. Other constructs that
- use references are:
+ Mnoho syntaktick�ch konstrukt� v PHP je implementov�no p�es odkazov�
+ mechanismus, tak�e v�e, co bylo �e�eno v��e o p�i�azov�n� referenc�,
+ plat� i na tyto konstrukty. N�kter� konstrukty, jako p�ed�v�n� a
+ vracen� p�es odkazy, byly ji� zm�n�ny. Ostatn� konstrukty pou��vaj�c�
+ reference jsou:
</simpara>
<sect2 id="references.global">
- <title><literal>global</literal> References</title>
+ <title>odkazy <literal>global</literal></title>
<para>
- When you declare variable as <command>global $var</command> you
- are in fact creating reference to a global variable. That means,
- this is the same as:
+ Kdy� deklarujete prom�nnou jako <command>global $var</command>, ve
+ skute�nosti vytv���te odkaz na glob�ln� prom�nnou. Tzn. je to tot�,
+ jako:
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -288,16 +281,16 @@
</informalexample>
</para>
<simpara>
- That means, for example, that unsetting <varname>$var</varname>
- won't unset global variable.
+ To znamen�, nap��klad, �e odnastaven� <varname>$var</varname>
+ neodnastav� glob�ln� prom�nnou.
</simpara>
</sect2>
<sect2 id="references.this">
<title><literal>$this</literal></title>
<simpara>
- In an object method, <varname>$this</varname> is always reference
- to the caller object.
+ V metod� objektu je <varname>$this</varname> v�dy odkazem na volaj�c�
+ objekt.
</simpara>
</sect2>
</sect1>
@@ -313,7 +306,7 @@
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
-indent-tabs-mode:nil
+ indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../manual.ced"
sgml-exposed-tags:nil
Index: phpdoc/cs/language/functions.xml
+++ phpdoc/cs/language/functions.xml
<?xml version="1.0" encoding="iso-8859-2"?>
<!-- EN-Revision: 1.25 Maintainer: luk Status: ready -->
<chapter id="functions">
<title>Funkce</title>
<sect1 id="functions.user-defined">
<title>U�ivatelsky definovan� funkce</title>
<para>
Funkce m��e b�t definov�na pomoc� syntaxe podobn� t�to:
<informalexample>
<programlisting role="php">
<![CDATA[
function foo ($arg_1, $arg_2, ..., $arg_n)
{
echo "Uk�zkov� funkce.\n";
return $retval;
}
]]>
</programlisting>
</informalexample>
</para>
<!--
status of func(const $param) ?
zend doesn't care at all whether or not you specify it.
I've never seen it before... what's its use? (or was...)
-->
<simpara>
Do funkce m��e b�t vlo�en jak�koli platn� PHP k�d, dokonce i definice
jin�ch funkc� a <link linkend="keyword.class">t��d</link>.
</simpara>
<simpara>
V PHP 3 mus� b�t funkce definov�ny d��ve, ne� je na n� odkazov�no.
V PHP u� tento po�adavek neplat�.
</simpara>
<simpara>
PHP nepodporuje p�et�ov�n� funkc�, nen� mo�n� ani oddefinov�n� nebo
p�edefinovan� d��ve deklarovan�ch funkc�.
</simpara>
<simpara>
PHP 3 nepodporuje prom�nn� po�et argument� funkc�, zat�mco implicitn�
argumenty jsou podporov�ny (v�ce informac� - viz
<link linkend="functions.arguments.default">Implicitn� hodnoty argument�</link>).
PHP 4 podporuje oboj�: v�ce informac� - viz
<link linkend="functions.variable-arg-list">Seznam argument� prom�nn�
d�lky</link> a reference funkc� <function>func_num_args</function>,
<function>func_get_arg</function>, a <function>func_get_args</function>.
</simpara>
</sect1>
<sect1 id="functions.arguments">
<title>Argumenty funkc�</title>
<simpara>
Informace mohou b�t do funkc� p�ed�v�ny p�es seznam argument�, co� je
seznam prom�nn�ch a/nebo konstant odd�len�ch ��rkou.
</simpara>
<para>
PHP podporuje p�ed�v�n� argument� hodnotou (implicitn�),
<link linkend="functions.arguments.by-reference">p�ed�v�n� odkazem</link>,
a <link linkend="functions.arguments.default">implicitn� hodnoty
argument�</link>. Prom�nn� d�lka seznamu argument� je podporov�na pouze
v PHP 4 a pozd�j��ch; viz
<link linkend="functions.variable-arg-list">Seznam argument� prom�nn�
d�lky</link> a reference funkc� <function>func_num_args</function>,
<function>func_get_arg</function>, a <function>func_get_args</function>.
Podobn� efekt m��e b�t v PHP 3 dosa�en p�ed�n�m pole argument� do
funkce:
<informalexample>
<programlisting role="php">
<![CDATA[
function takes_array($input)
{
echo "$input[0] + $input[1] = ", $input[0]+$input[1];
}
]]>
</programlisting>
</informalexample>
</para>
<sect2 id="functions.arguments.by-reference">
<title>P�ed�v�n� argument� odkazem</title>
<simpara>
Implicitn� jsou argumenty funkc� p�ed�v�ny hodnotou (tak�e kdy� zm�n�te
hodnotu argumentu ve funkci, nezm�n� se mimo funkci). Pokud chcete
umo�nit funkci modifikovat sv� argumenty, mus�te je p�ed�vat odkazem.
</simpara>
<para>
Pokud chcete, aby byl argument do funkce p�ed�v�n v�dy odkazem, m��ete
p�ed n�zev argumentu v definici funkce p�ed�adit ampersand (&):
<informalexample>
<programlisting role="php">
<![CDATA[
function add_some_extra(&$string)
{
$string .= 'a n�co nav�c.';
}
$str = 'Toto je �et�zec ';
add_some_extra($str);
echo $str; // vyp��e 'Toto je �et�zec a n�co nav�c.'
]]>
</programlisting>
</informalexample>
</para>
</sect2>
<sect2 id="functions.arguments.default">
<title>Implicitn� hodnoty argument�</title>
<para>
Funkce m��e ve stylu C++ definovat implicitn� hodnoty pro skal�rn�
argumenty takto:
<informalexample>
<programlisting role="php">
<![CDATA[
function makecoffee ($type = "cappucina")
{
return "D�l�m ��lek $type.\n";
}
echo makecoffee ();
echo makecoffee ("espressa");
]]>
</programlisting>
</informalexample>
</para>
<para>
V�stupem v��e uveden�ho k�du je:
<screen>
D�l�m ��lek cappucina.
D�l�m ��lek espressa.
</screen>
</para>
<simpara>
Implicitn� hodnota mus� b�t konstantn� v�raz, ne (nap��klad) prom�nn�
nebo polo�ka t��dy.
</simpara>
<para>
Uv�domte si, �e kdy� pou��v�te implicitn� argumenty, jak�koli implicitn�
hodnoty by m�ly b�t na prav� stan� neimplicitn�ho argumentu; jinak
to nebude pracovat podle o�ek�v�n�. Uva�ujme tento kus k�du:
<informalexample>
<programlisting role="php">
<![CDATA[
function makeyogurt ($type = "acidophilus", $flavour)
{
return "D�l�m kel�mek jogurtu $type $flavour.\n";
}
echo makeyogurt ("malina"); // nebude pracovat podle o�ek�v�n�
]]>
</programlisting>
</informalexample>
</para>
<para>
V�stupem uveden�ho p��kladu bude:
<screen>
Warning: Missing argument 2 in call to makeyogurt() in
/usr/local/etc/httpd/htdocs/php3test/functest.html on line 41
D�l�m kel�mek jogurtu malina.
</screen>
</para>
<para>
A nyn� to porovnejme s t�mto:
<informalexample>
<programlisting role="php">
<![CDATA[
function makeyogurt ($flavour, $type = "acidophilus")
{
return "D�l�m kel�mek jogurtu $type $flavour.\n";
}
echo makeyogurt ("malina"); // pracuje podle o�ek�v�n�
]]>
</programlisting>
</informalexample>
</para>
<para>
P��klad vytiskne:
<screen>
D�l�m kel�mek jogurtu acidophilus malina.
</screen>
</para>
</sect2>
<sect2 id="functions.variable-arg-list">
<title>Seznam argument� prom�nn� d�lky</title>
<simpara>
PHP 4 m� podporu pro seznam argument� prom�nn� d�lky v u�ivatelsk�ch
funkc�ch. Je to opravdu jednoduch�, pou�it�m funkc�
<function>func_num_args</function>,
<function>func_get_arg</function>, a
<function>func_get_args</function>.
</simpara>
<simpara>
Nen� t�eba ��dn� zvl�tn� syntaxe, seznam argument� m��e b�t st�le
explicitn� poskytov�n definicemi funkc� a bude se chovat jako norm�ln�.
</simpara>
</sect2>
</sect1>
<sect1 id="functions.returning-values">
<title>N�vratov� hodnoty</title>
<para>
Hodnoty jsou vraceny pomoc� nepovinn� klausule return. M��e b�t vracen
libovoln� typ, v�etn� seznam� a objekt�. Klasule zp�sobuje, �e funkce
okam�it� ukon�� sv�j b�h a p�ed� ��zen� zp�t na ��dek, odkud byla vol�na.
Pro v�ce informac� viz <function>return</function>.
<informalexample>
<programlisting role="php">
<![CDATA[
function square ($num)
{
return $num * $num;
}
echo square (4); // vyp��e '16'.
]]>
</programlisting>
</informalexample>
</para>
<para>
Z funkce nem��ete vracet v�ce hodnot, ale podobn�ho v�sledku m��e b�t
dosa�eno vr�cen�m seznamu.
<informalexample>
<programlisting role="php">
<![CDATA[
function small_numbers()
{
return array (0, 1, 2);
}
list ($zero, $one, $two) = small_numbers();
]]>
</programlisting>
</informalexample>
</para>
<para>
K vr�cen� odkazu z funkce mus�te pou��t referen�n� oper�tor & jak
v deklaraci funkce, tak p�i p�i�azov�n� vr�cen� hodnoty do prom�nn�:
<informalexample>
<programlisting role="php">
<![CDATA[
function &returns_reference()
{
return $someref;
}
$newref =& returns_reference();
]]>
</programlisting>
</informalexample>
</para>
<simpara>
Pro dal�� informace o odkazech se laskav� pod�vejte na
<link linkend="language.references">Vysv�tlen� odkaz�</link>.
</simpara>
</sect1>
<sect1 id="functions.old-syntax">
<title><literal>old_function</literal></title>
<simpara>
Klausule <literal>old_function</literal> umo��uje deklarovat funkci
s identickou syntax� jako v PHP/FI2 (krom� toho, �e mus�te 'function'
nahradit 'old_function'.
</simpara>
<simpara>
Toto je zavr�en� mo�nost a m�la by b�t pou��v�na pouze PHP/FI2->PHP 3
konvertorem.
</simpara>
<warning>
<para>
Funkce deklarovan� jako <literal>old_function</literal> nelze volat
z intern�ho k�du PHP. To mj. znamen�, �e je nem��ete pou��vat ve funkc�ch
jako <function>usort</function>, <function>array_walk</function>, a
<function>register_shutdown_function</function>. Toto omezen� m��ete
obej�t naps�n�m wrapperu (v norm�ln� PHP 3 form�), z n�ho� vol�te
<literal>old_function</literal>.
</para>
</warning>
</sect1>
<sect1 id="functions.variable-functions">
<title>Funkce v prom�nn�ch</title>
<para>
PHP podporuje koncept funkc� v prom�nn�ch. To znamen�, �e kdy�
m� n�zev prom�nn� p�ipojeny z�vorky, PHP bude hledat funkci se stejn�m
n�zvem, jako m� hodnota prom�nn�, a pokus� se ji prov�st. To lze mj.
pou��t k implementac� zp�tn�ch vol�n�, tabulek funkc� atd.
</para>
<para>
Funkce v prom�nn�ch nebudou fungovat s jazykov�mi konstrukty jin�mi ne�
<function>print</function>, jako je <function>echo</function>,
<function>unset</function>, <function>isset</function> a
<function>empty</function>. To je jeden z velk�ch rozd�l� mezi funkcemi
PHP a jazykov�mi konstrukty.
</para>
<para>
<example>
<title>P��klad na funkce v prom�nn�ch</title>
<programlisting role="php">
<![CDATA[
<?php
function foo()
{
echo "V foo()<br>\n";
}
function bar($arg = '')
{
echo "V bar(); byl argument '$arg'.<br>\n";
}
$func = 'foo';
$func();
$func = 'bar';
$func('test');
?>
]]>
</programlisting>
</example>
</para>
</sect1>
</chapter>
<!-- 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:
-->