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>&amp;</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>&amp;</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>&amp;</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>&amp;</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>&amp;</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>&amp;</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 (&amp;):
 
     <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 &amp; 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:
 -->

Reply via email to