cvs: phpdoc /cs translation.xml /cs/language functions.xml references.xml

From: Date: Sun, 17 Mar 2002 22:16:10 +0000
Subject: cvs: phpdoc /cs translation.xml /cs/language functions.xml references.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969343160@lists.php.net to get a copy of this message
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: -->
« previous php.doc (#969343160) next »