cvs: phpdoc-si /language functions.xml
[email protected] ("Dejan Markic") Wed, 04 Sep 2002 13:44:49 -0000
| Newsgroups | php.doc.sl |
|---|---|
| Message-ID | <cvsdejan1031147089@cvsserver> |
dejan Wed Sep 4 09:44:49 2002 EDT
Modified files:
/phpdoc-si/language functions.xml
Log:
Done.
dejan-20020904094449.txt
(text/plain, 15.9 KB)
Index: phpdoc-si/language/functions.xml
diff -u phpdoc-si/language/functions.xml:1.1 phpdoc-si/language/functions.xml:1.2
--- phpdoc-si/language/functions.xml:1.1 Tue Sep 3 09:48:29 2002
+++ phpdoc-si/language/functions.xml Wed Sep 4 09:44:48 2002
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<!-- $EN-Revision: 1.28 Maintainer: dejan Status: working -->
<chapter id="functions">
- <title>Functions</title>
+ <title>Funkcije</title>
<sect1 id="functions.user-defined">
- <title>User-defined functions</title>
+ <title>Uporabniške funkcije</title>
<para>
- A function may be defined using syntax such as the following:
+ Funkcijo lahko definiramo z naslednjo sintakso:
<informalexample>
<programlisting role="php">
<![CDATA[
function foo ($arg_1, $arg_2, ..., $arg_n)
{
- echo "Example function.\n";
+ echo "Primer funkcije.\n";
return $retval;
}
]]>
@@ -32,53 +32,53 @@
-->
<simpara>
- Any valid PHP code may appear inside a function, even other
- functions and <link linkend="keyword.class">class</link>
- definitions.
+ V funkciji se lahko uporabi vsaka veljavna PHP koda, tudi ostale
+ funkcije ali celo <link linkend="keyword.class">razredne</link>
+ definicije.
</simpara>
<simpara>
- In PHP 3, functions must be defined before they are referenced. No
- such requirement exists in PHP 4.
+ V PHP 3 morajo biti funkcije definirane pred uporabo, kar ne velja
+ za PHP 4.
</simpara>
<simpara>
- PHP does not support function overloading, nor is it possible to
- undefine or redefine previously-declared functions.
+ PHP ne podpira brisanje definicije ali redefinicijo prej deklarirane
+ funkcije.
</simpara>
<simpara>
- PHP 3 does not support variable numbers of arguments to functions,
- although default arguments are supported (see <link
- linkend="functions.arguments.default">Default argument
- values</link> for more information). PHP 4 supports both: see <link
- linkend="functions.variable-arg-list">Variable-length argument
- lists</link> and the function references for
- <function>func_num_args</function>,
- <function>func_get_arg</function>, and
- <function>func_get_args</function> for more information.
+ PHP 3 ne podpira poljubno število argumentov za funckijo, čeprav
+ podpira privzete argumente (poglejte si <link
+ linkend="functions.arguments.default">Privzeti argumenti</link>
+ za več informacij). PHP 4 podpira oboje: poglejte si <link
+ linkend="functions.variable-arg-list">Poljubno število argumentov</link>
+ in reference funkcij
+ <function>func_num_args</function>,
+ <function>func_get_arg</function> in
+ <function>func_get_args</function> za več informacij.
</simpara>
</sect1>
<sect1 id="functions.arguments">
- <title>Function arguments</title>
+ <title>Argumenti funkcij</title>
<simpara>
- Information may be passed to functions via the argument list,
- which is a comma-delimited list of variables and/or constants.
+ Informacije funkciji so lahko podane kot spisek argumentov, kar
+ je z vejico razdeljen spisek spremenljivk in/ali konstant.
</simpara>
<para>
- PHP supports passing arguments by value (the default), <link
- linkend="functions.arguments.by-reference">passing by
- reference</link>, and <link
- linkend="functions.arguments.default">default argument
- values</link>. Variable-length argument lists are supported only
- in PHP 4 and later; see <link
- linkend="functions.variable-arg-list">Variable-length argument
- lists</link> and the function references for
+ PHP podpira podajanje argumentov po vrednosti (privzeto), <link
+ linkend="functions.arguments.by-reference">po referenci</link>
+ in <link
+ linkend="functions.arguments.default">privzete vrednosti argumentov</link>.
+ Poljubno število argumentov podpirajo PHP verzije 4 ali več;
+ poglejte si <link
+ linkend="functions.variable-arg-list">poljubno število argumentov</link>
+ in reference funkcij
<function>func_num_args</function>,
- <function>func_get_arg</function>, and
- <function>func_get_args</function> for more information. A
- similar effect can be achieved in PHP 3 by passing an array of
- arguments to a function:
+ <function>func_get_arg</function> in
+ <function>func_get_args</function> za več informacij.
+ Podoben efekt lahko dosežemo v PHP 3, če pošljemo
+ polje kot argument funkciji:
<informalexample>
<programlisting role="php">
@@ -93,30 +93,28 @@
</para>
<sect2 id="functions.arguments.by-reference">
- <title>Making arguments be passed by reference</title>
+ <title>Podajanje argumentov po referenci</title>
<simpara>
- By default, function arguments are passed by value (so that if
- you change the value of the argument within the function, it does
- not get changed outside of the function). If you wish to allow a
- function to modify its arguments, you must pass them by
- reference.
+ Privzeto se argumenti funkcij podajajo po vrednosti (torej, če spremenite
+ vrednost argumenta v funkciji, se vrednost ne spremeni zunaj funkcije).
+ Če želite funkciji dovoliti, da spreminja svoje argumente, morate
+ argumente podati po referenci.
</simpara>
<para>
- If you want an argument to a function to always be passed by
- reference, you can prepend an ampersand (&) to the argument
- name in the function definition:
-
+ Če želimo da je argument funkcije vedno podan po referenci,
+ moramo dodati 'in' znak (&) pred ime argumenta v definiciji
+ funkcije:
<informalexample>
<programlisting role="php">
<![CDATA[
function add_some_extra(&$string)
{
- $string .= 'and something extra.';
+ $string .= 'dodaj k nizu.';
}
-$str = 'This is a string, ';
+$str = 'To je niz, ';
add_some_extra($str);
-echo $str; // outputs 'This is a string, and something extra.'
+echo $str; // izpise 'To je niz, dodaj k nizu'
]]>
</programlisting>
</informalexample>
@@ -125,18 +123,18 @@
</sect2>
<sect2 id="functions.arguments.default">
- <title>Default argument values</title>
+ <title>Privzete vrednosti argumentov</title>
<para>
- A function may define C++-style default values for scalar
- arguments as follows:
+ Funkcija lahko definira privzete vrednost za skalarne vrednosti, kot
+ se to da v C++:
<informalexample>
<programlisting role="php">
<![CDATA[
function makecoffee ($type = "cappuccino")
{
- return "Making a cup of $type.\n";
+ return "Tip kave: $type.\n";
}
echo makecoffee ();
echo makecoffee ("espresso");
@@ -146,89 +144,89 @@
</para>
<para>
- The output from the above snippet is:
+ Izpis zgornjega primera je:
<screen>
-Making a cup of cappuccino.
-Making a cup of espresso.
+Tip kave: cappuccino.
+Tip kave: espresso.
</screen>
</para>
<simpara>
- The default value must be a constant expression, not (for
- example) a variable or class member.
+ Privzeta vrednost mora biti konstantni izraz in ne (naprimer)
+ spremenljivka ali član razreda.
</simpara>
<para>
- Note that when using default arguments, any defaults should be on
- the right side of any non-default arguments; otherwise, things
- will not work as expected. Consider the following code snippet:
+ Zapomnite si, da morajo biti privzeti argumenti desno od tistih
+ ne-privzetih argumentov; sicer stvari ne bodo potekale kot
+ bi pričakovali. Poglejte si naslednji pirmer:
<informalexample>
<programlisting role="php">
<![CDATA[
function makeyogurt ($type = "acidophilus", $flavour)
{
- return "Making a bowl of $type $flavour.\n";
+ return "Naredi posodo $type $flavour.\n";
}
-echo makeyogurt ("raspberry"); // won't work as expected
+echo makeyogurt ("raspberry"); // ne bo delalo kot bi si zeleli
]]>
</programlisting>
</informalexample>
</para>
<para>
- The output of the above example is:
+ Ta primer bi izpisal:
<screen>
Warning: Missing argument 2 in call to makeyogurt() in
/usr/local/etc/httpd/htdocs/php3test/functest.html on line 41
-Making a bowl of raspberry .
+Naredi posodo raspberry .
</screen>
</para>
<para>
- Now, compare the above with this:
+ Zdaj pa primerjajte zgornji primer z naslednjim:
<informalexample>
<programlisting role="php">
<![CDATA[
function makeyogurt ($flavour, $type = "acidophilus")
{
- return "Making a bowl of $type $flavour.\n";
+ return "Naredi posodo $type $flavour.\n";
}
-echo makeyogurt ("raspberry"); // works as expected
+echo makeyogurt ("raspberry"); // dela kot pricakujemo
]]>
</programlisting>
</informalexample>
</para>
<para>
- The output of this example is:
+ Ta primer bi izpisal:
<screen>
-Making a bowl of acidophilus raspberry.
+Naredi posodo acidophilus raspberry.
</screen>
</para>
</sect2>
<sect2 id="functions.variable-arg-list">
- <title>Variable-length argument lists</title>
+ <title>Poljubno število argumentov</title>
<simpara>
- PHP 4 has support for variable-length argument lists in
- user-defined functions. This is really quite easy, using the
- <function>func_num_args</function>,
- <function>func_get_arg</function>, and
- <function>func_get_args</function> functions.
+ PHP 4 podpira poljubno število argumentov v uporabniških
+ funkcijah. Stvar je dosti enostavna z uporabo
+ <function>func_num_args</function>,
+ <function>func_get_arg</function> in
+ <function>func_get_args</function> funkcij.
</simpara>
<simpara>
- No special syntax is required, and argument lists may still be
- explicitly provided with function definitions and will behave as
- normal.
+ Ni potrebna nobena posebna sintaksa in argumenti so še vedno
+ lahko izrecno podani z definicijo funkcije in se bodo obnašali
+ normalno.
</simpara>
</sect2>
@@ -236,14 +234,13 @@
</sect1>
<sect1 id="functions.returning-values">
- <title>Returning values</title>
+ <title>Vračanje vrednosti</title>
<para>
- Values are returned by using the optional return statement. Any
- type may be returned, including lists and objects. This causes the
- function to end its execution immediately and pass control back to
- the line from which it was called. See <function>return</function>
- for more information.
+ Vrednosti so lahko vrnjene s pomočjo neobveznega return stavka.
+ Vrnemo lahko bilokateri tip spremelnjivke. To konča izvajanje
+ trenutne funkcija in skripta se normalno nadaljuje. Poglejte si
+ <function>return</function> za več informacij.
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -251,15 +248,15 @@
{
return $num * $num;
}
-echo square (4); // outputs '16'.
+echo square (4); // izpise '16'.
]]>
</programlisting>
</informalexample>
</para>
<para>
- You can't return multiple values from a function, but similar
- results can be obtained by returning a list.
+ Iz funkcije ne morete vrniti več vrednosti, lahko pa vrnete niz
+ in z list() dobite ven rezultate.
<informalexample>
<programlisting role="php">
@@ -274,9 +271,9 @@
</informalexample>
</para>
<para>
- To return a reference from a function, you have to use
- the reference operator & in both the function declaration and
- when assigning the returned value to a variable:
+ Če želite vrniti referenco iz funkcije, morate uporabiti
+ referenčni operator & v funkciji in ko dodeljujete
+ vrnjeno vrednost spremenljivki:
<informalexample>
<programlisting role="php">
<![CDATA[
@@ -291,8 +288,8 @@
</informalexample>
</para>
<simpara>
- For more information on references, please check out <link
- linkend="language.references">References Explained</link>.
+ Za več informacij o referencah si oglejte <link
+ linkend="language.references">Razložene reference</link>.
</simpara>
</sect1>
@@ -300,58 +297,59 @@
<title><literal>old_function</literal></title>
<simpara>
- The <literal>old_function</literal> statement allows you to
- declare a function using a syntax identical to PHP/FI2 (except you
- must replace 'function' with 'old_function'.
+ <literal>old_function</literal> stavek vam omogča deklariranje
+ funkcij z uporabe sintakse, ki je identična sintaksi v PHP/FI2 (zamenjati
+ morate 'function' z 'old_function').
</simpara>
<simpara>
- This is a deprecated feature, and should only be used by the
- PHP/FI2->PHP 3 convertor.
+ Uporaba tega je odsvetovana in bi jo moral uporabljati samo
+ PHP/FI2->PHP 3 konvertor.
</simpara>
<warning>
<para>
- Functions declared as <literal>old_function</literal> cannot be
- called from PHP's internal code. Among other things, this means
- you can't use them in functions such as
- <function>usort</function>, <function>array_walk</function>, and
- <function>register_shutdown_function</function>. You can get
- around this limitation by writing a wrapper function (in normal
- PHP 3 form) to call the <literal>old_function</literal>.
+ Funkcije deklarirane kot <literal>old_function</literal> ne morejo
+ biti klicane iz PHP interne kode. Poleh drugi stvari, to pomeni, da
+ jih ne morete uporabljati v funkcijah kot so
+ <function>usort</function>, <function>array_walk</function> in
+ <function>register_shutdown_function</function>. To omejitev
+ lahko obidete tako, da napišete navadno funkcijo, ki bo klicala
+ <literal>old_function</literal>.
+
</para>
</warning>
</sect1>
<sect1 id="functions.variable-functions">
- <title>Variable functions</title>
+ <title>Variabilne funkcije</title>
<para>
- PHP supports the concept of variable functions. This means that if
- a variable name has parentheses appended to it, PHP will look for
- a function with the same name as whatever the variable evaluates
- to, and will attempt to execute it. Among other things, this can
- be used to implement callbacks, function tables, and so forth.
+ PHP podpira koncept variabilnih funkcij. To pomeni, da če
+ imenu spremenljivke dodamo oklepaje na koncu, bo PHP poiskal
+ funkcijo, ki ima ime vrednosti te spremenljivke, in jo skušal
+ izvesti. Ta koncept je lahko uporabljen pri naprimer tabelah
+ funkcij in tako naprej.
</para>
<para>
- Variable functions won't work with language constructs such
- as <function>echo</function>, <function>unset</function>,
+ Variabilne funkcije ne bodo delale z funkcijami ki so del PHP-ja, kot so
+ <function>echo</function>, <function>unset</function>,
<function>isset</function>, <function>empty</function>,
- <function>include</function> and <function>print</function>.
+ <function>include</function> in <function>print</function>.
</para>
<para>
<example>
- <title>Variable function example</title>
+ <title>Primer variabilne funkcije</title>
<programlisting role="php">
<![CDATA[
<?php
function foo()
{
- echo "In foo()<br>\n";
+ echo "V foo()<br>\n";
}
function bar($arg = '')
{
- echo "In bar(); argument was '$arg'.<br>\n";
+ echo "V bar(); je argument '$arg'.<br>\n";
}
$func = 'foo';
@@ -364,8 +362,8 @@
</example>
</para>
<para>
- See also <link linkend="language.variables.variable">
- variable variables</link> and <function>function_exists</function>.
+ Poglejte si tudi <link linkend="language.variables.variable">
+ variabilne spremenljivke</link> in <function>function_exists</function>.
</para>
</sect1>