leszek Tue Oct 30 07:31:03 2001 EDT
Modified files:
/phpdoc/pl Translators bookinfo.xml language-snippets.ent
/phpdoc/pl/functions mysql.xml
/phpdoc/pl/language constants.xml oop.xml
Log:
Update: new chapter, updated some other chapters
Index: phpdoc/pl/Translators
diff -u phpdoc/pl/Translators:1.2 phpdoc/pl/Translators:1.3
--- phpdoc/pl/Translators:1.2 Tue Oct 23 12:12:40 2001
+++ phpdoc/pl/Translators Tue Oct 30 07:31:01 2001
@@ -2,6 +2,7 @@
Polish PHP Documentation Translation Team Member List (PPDTTML? :)
DomBal Marcin D�browski [EMAIL PROTECTED]
+kurtz Wojciech Jukowski [EMAIL PROTECTED]
Leon Leszek Krupi�ski [EMAIL PROTECTED]
Yagood Pawe� Paprota [EMAIL PROTECTED]
slawek S�awomir Pucia [EMAIL PROTECTED]
@@ -58,7 +59,7 @@
aspell.xml
bc.xml
bzip2.xml
-calendar.xml
+calendar.xml kurtz started 1.15
ccvs.xml
classobj.xml
com.xml
@@ -67,13 +68,13 @@
curl.xml
cybercash.xml
cybermut.xml
-datetime.xml
+datetime.xml kurtz started 1.49
dba.xml
dbase.xml
dbm.xml
dbplus.xml
dbx.xml
-dir.xml
+dir.xml kurtz started 1.21
domxml.xml
errorfunc.xml
exec.xml
@@ -85,7 +86,7 @@
funchand.xml
gettext.xml
gmp.xml
-http.xml Qrak done ?.??
+http.xml Qrak done 1.28
hw.xml
ibase.xml
icap.xml
@@ -99,7 +100,7 @@
java.xml
ldap.xml
mail.xml Qrak done 1.29
-math.xml Qrak started ?.??
+math.xml Qrak started 1.55
mbstring.xml
mcal.xml
mcrypt.xml
@@ -131,11 +132,11 @@
satellite.xml
sem.xml
sesam.xml
-session.xml
+session.xml leon started 1.53
shmop.xml
snmp.xml
sockets.xml
-strings.xml
+strings.xml kurtz started 1.117
swf.xml
sybase.xml
uodbc.xml
@@ -153,7 +154,7 @@
control-structures.xml
expressions.xml Leon done 1.14
functions.xml Leon done 1.17
-oop.xml Leon started 1.28
+oop.xml Leon done 1.28
operators.xml Qrak started 1.27
references.xml
types.xml
Index: phpdoc/pl/bookinfo.xml
diff -u phpdoc/pl/bookinfo.xml:1.2 phpdoc/pl/bookinfo.xml:1.3
--- phpdoc/pl/bookinfo.xml:1.2 Tue Oct 23 12:15:00 2001
+++ phpdoc/pl/bookinfo.xml Tue Oct 30 07:31:01 2001
@@ -1,5 +1,5 @@
<?xml encoding="iso-8859-2"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<bookinfo id="bookinfo">
<authorgroup id="authors">
@@ -62,9 +62,6 @@
</collab>
<collab>
<collabname>Marcin D�browski</collabname>
- </collab>
- <collab>
- <collabname>Pawe� Paprota</collabname>
</collab>
</authorgroup>
Index: phpdoc/pl/language-snippets.ent
diff -u phpdoc/pl/language-snippets.ent:1.1 phpdoc/pl/language-snippets.ent:1.2
--- phpdoc/pl/language-snippets.ent:1.1 Tue Oct 23 07:19:35 2001
+++ phpdoc/pl/language-snippets.ent Tue Oct 30 07:31:02 2001
@@ -1,7 +1,7 @@
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<!ENTITY warn.experimental '<warning><simpara>Ten modu� jest w stadium
<emphasis>EKSPERYMENTALNYM</emphasis>. Oznacza to, �e zachowanie tych funkcji, ich
nazwy, w zasadzie WSZYSTKO udokumentowane tutaj mo�e zosta� zmienione w przysz�ych
wersjach PHP BEZ WCZE�NIEJSZEGO UPRZEDZENIA. U�ywaj tego modu�u na w�asne
ryzyko.</simpara></warning>'>
-<!ENTITY warn.experimental.func '<warning><simpara>Ta funkcja jest w stadium
<emphasis>EKSPERYMENTALNYM</emphasis>. Oznacza to, �e zachowanie teh funkcji, jej
nazwa, w zasadzie wszystko udokumentowane tutaj mo�e zosta� zmienione w przysz�ych
wersjach PHP BEZ WCZE�NIEJSZEGO UPRZEDZENIA. U�ywaj tej funkcji na w�asne
ryzyko.</simpara></warning>'>
+<!ENTITY warn.experimental.func '<warning><simpara>Ta funkcja jest w stadium
+<emphasis>EKSPERYMENTALNYM</emphasis>. Oznacza to, �e zachowanie funkcji, jej nazwa,
+w zasadzie wszystko udokumentowane tutaj mo�e zosta� zmienione w przysz�ych wersjach
+PHP BEZ WCZE�NIEJSZEGO UPRZEDZENIA. U�ywaj tej funkcji na w�asne
+ryzyko.</simpara></warning>'>
<!ENTITY tip.ob-capture '<tip><simpara>Ze wszystkim, co wysy�a dane bezpo�rednio do
przegl�darki, mo�esz u�ywa� <link linkend="ref.outcontrol">funkcji kontroli
wyj�cia</link> aby przej�� wyj�cie tej funkcji i zapisa� je - na przyk�ad - w zmiennej
tekstowej.</simpara></tip>'>
Index: phpdoc/pl/functions/mysql.xml
diff -u phpdoc/pl/functions/mysql.xml:1.1 phpdoc/pl/functions/mysql.xml:1.2
--- phpdoc/pl/functions/mysql.xml:1.1 Tue Oct 23 07:19:36 2001
+++ phpdoc/pl/functions/mysql.xml Tue Oct 30 07:31:02 2001
@@ -1,5 +1,5 @@
<?xml encoding="iso-8859-2"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<reference id="ref.mysql">
<title>Funkcje MySQL</title>
<titleabbrev>MySQL</titleabbrev>
@@ -1760,8 +1760,8 @@
</para>
</note>
<para>
- <function>mysql_query</function> zwraca &true; (nie-zero) lub &false;
- informuj�c czy zapytanie zako�czy�o si� sukcesem lub te� nie.
+ <function>mysql_query</function> zwraca &true; lub &false;
+ informuj�c czy zapytanie zako�czy�o si� sukcesem czy te� nie.
Zwr�cona warto�� &true; oznacza, �e zapytanie by�o prawid�owe i
mo�e by� wykonane przez serwer. Nie m�wi natomiast nic o liczbie
przetworzonych lub zwr�conych wierszy. Jest r�wnie� mo�liwe, �e
Index: phpdoc/pl/language/constants.xml
diff -u phpdoc/pl/language/constants.xml:1.1 phpdoc/pl/language/constants.xml:1.2
--- phpdoc/pl/language/constants.xml:1.1 Tue Oct 23 07:19:37 2001
+++ phpdoc/pl/language/constants.xml Tue Oct 30 07:31:02 2001
@@ -1,244 +1,244 @@
-<?xml encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<?xml encoding="iso-8859-2"?>
+<!-- $Revision: 1.2 $ -->
<chapter id="language.constants">
- <title>Constants</title>
+ <title>Sta�e</title>
<simpara>
- A constant is a identifier (name) for a simple value. As the name
- suggests, that value cannot change during the execution of the script
- (the magic constants <constant>__FILE__</constant> and
- <constant>__LINE__</constant> are the only exception). A constant
- is case-sensitive by default. By convention constants are always
- uppercase.
+ Sta�a jest identyfikatorem (nazw�) dla prostej warto�ci. Jak sama
+ nazwa wskazuje, warto�� ta nie mo�e si� zmienia� podczas dzia�ania
+ skryptu (poza wyj�tkami: <constant>__FILE__</constant>
+ i <constant>__LINE__</constant>). Domy�lnie, przy sta�ych
+ uwzgl�dniana jest wielko�� liter. Przyj�to, �e sta�e s� pisane du�ymi
+ literami.
</simpara>
<para>
- The name of a constant follows the same rules as any label in PHP. A
- valid constant name starts with a letter or underscore, followed
- by any number of letters, numbers, or underscores. As a regular
- expression, it would be expressed thus:
+ Nazwa sta�ej podlega takim samym zasadom jak ka�da inna w PHP.
+ Prawid�owa nazwa sta�ej rozpoczyna si� liter�, znakiem podkre�lenia
+ ("_"), nast�pnie mog� wyst�powa� litery, cyfry lub znaki podkre�lenia.
+ Dobrze reprezentuje to takie wyra�enie regularne:
<literal>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*</literal>
<!-- TODO: Example of valid & invalid constant names -->
</para>
-
+
<note>
<simpara>
- For our purposes here, a letter is a-z, A-Z, and the ASCII
- characters from 127 through 255 (0x7f-0xff).
+ Na nasze potrzeby, litery to a-z, A-Z, oraz znaki ASCII
+ od 127 do 255 (0x7f-0xff).
</simpara>
</note>
<simpara>
- The scope of a constant is global.
+ Zakres sta�ej jest globalny.
</simpara>
<sect1 id="language.constants.syntax">
- <title>Syntax</title>
+ <title>Sk�adnia</title>
<simpara>
- You can define a constant by using the
- <function>define</function>-function. Once a constant is defined,
- it can never be changed or undefined.
+ Mo�esz definiowa� sta�� u�ywaj�c funkcji <function>define</function>.
+ Kiedy sta�a zostanie zdefiniowana, nie mo�e by� ju� zmieniona albo
+ undefined.
</simpara>
<simpara>
- Only scalar data (<type>boolean</type>, <type>integer</type>,
- <type>double</type> and <type>string</type>) can be contained
- in constants.
+ Tylko skalarne typy danych
+ (<type>boolean</type>, <type>integer</type>, <type>double</type>
+ i <type>string</type>) mog� by� zawarte w sta�ych.
</simpara>
<simpara>
- You can get the value of a constant by simply specifying its name.
- Unlike with variables, you should <emphasis>not</emphasis> prepend
- a constant with a <literal>$</literal>.
- You can also use the function <function>constant</function>, to
- read a constant's value, if you are to obtain the constant's name
- dynamically.
- Use <function>get_defined_constants</function> to get a list of
- all defined constants.
+ Mo�esz u�y� warto�ci sta�ej poprzez zwyk�e u�ycie jej nazwy.
+ Inaczej ni� przy zmiennych, w sta�ych <emphasis>NIE</emphasis>
+ powiniene� prepend sta�ej znakiem <literal>$</literal>.
+ Mo�esz tak�e u�y� funkcji <function>constant</function>, aby
+ odczyta� warto�� sta�ej, kt�rej nazwa jest przekazywana dynamicznie.
+ U�yj funkcji <function>get_defined_constants</function> aby otrzyma�
+ list� zdefiniowanych sta�ych.
</simpara>
<note>
<simpara>
- Constants and (global) variables are in a different namespace.
- This implies that for example &true; and
- <varname>$TRUE</varname> are generally different.
+ Sta�e i globlane zmienne s� pisane inaczej, a to oznacza, �e np.
+ &true; i <varname>$TRUE</varname> s� r�ne.
</simpara>
</note>
<simpara>
- If you use an undefined constant, PHP assumes that you mean
- the name of the constant itself. A
- <link linkend="features.error-handling">notice</link> will be issued
- when this happens. Use the <function>defined</function>-function if
- you want to know if a constant is set.
+ Je�li u�yjesz niezdefiniowanej sta�ej, PHP przyjmuje, �e chcesz u�y�
+ nazwy sta�ej samej w sobie. Zostanie wtedy wys�ane
+ <link linkend="features.error-handling">ostrze�enie</link>.
+ U�yj funkcji <function>defined</function> je�li chcesz si� dowiedzie�
+ czy sta�a jest zdefiniowana.
</simpara>
<para>
- This are the differences with variables:
+ R�nice pomi�dzy sta�ymi, a zmiennymi:
<itemizedlist>
<listitem>
<simpara>
- Constants do not have a dollar sign (<literal>$</literal>) before them;
+ Sta�e nie maj� znaku dolara (<literal>$</literal>) przed nazw�;
</simpara>
</listitem>
<listitem>
<simpara>
- Constants may be defined and accessed anywhere without regard to variable
- scoping rules;
+ Sta�e mog� by� definiowane oraz u�ywane wsz�dzie bez zwa�ania na
+ zasady dotycz�ce zakresu ich dost�pno�ci;
</simpara>
</listitem>
<listitem>
<simpara>
- Constants may not be redefined or undefined once they have
- been set; and
+ Sta�e nie mog� by� redefiniowane lub undefined po tym jak raz zosta�y
+ zdefiniowane; i
</simpara>
</listitem>
<listitem>
<simpara>
- Constants may only evaluate to scalar values.
+ Sta�e mog� zawiera� tylko warto�ci skalarne.
</simpara>
</listitem>
</itemizedlist>
</para>
-
+
<para>
<example>
- <title>Defining Constants</title>
+ <title>Definiowanie sta�ych</title>
<programlisting>
<?php
-define("CONSTANT", "Hello world.");
-echo CONSTANT; // outputs "Hello world."
-echo Constant; // outputs "Constant" and issues a notice.
+define("STALA", "Hello world!");
+echo STALA; // wy�wietli "Hello world!"
+echo Stala; // wy�wietli "Stala" i zg�osi ostrze�enie
?>
</programlisting>
</example>
</para>
-
+
</sect1>
-
+
<sect1 id="language.constants.predefined">
- <title>Predefined constants</title>
+ <title>Predefiniowane sta�e</title>
<para>
- The predefined constants (always available) are:
+ Predefiniowanymi sta�ymi (zawsze dost�pnymi) s�:
<variablelist>
<varlistentry>
- <term>__FILE__ (case-insensitive)</term>
+ <term>__FILE__ (niewa�na wielko�� liter)</term>
<listitem>
<simpara>
- The name of the script file presently being parsed. If used
- within a file which has been included or required, then the
- name of the included file is given, and not the name of the
- parent file.
+ Nazwa pliku ze skryptem PHP, kt�ry jest aktualnie parsowany
+ (przetwarzany); sta�a u�yta w pliku, kt�ry zosta�, kt�ry zosta�
+ w��czony (include) lub jest wymagany (require), zwraca nazw�
+ tego w�a�nie pliku, a nie nazw� pliku g��wnego.
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
- <term>__LINE__ (case-insensitive)</term>
+ <term>__LINE__ (niewa�na wielko�� liter)</term>
<listitem>
<simpara>
- The number of the line within the current script file which is
- being parsed. If used within a file which has been included or
- required, then the position within the included file is given.
+ Numer linii w pliku, kt�ry jest aktualnie parsowany (przetwarzany).
+ Sta�a u�yta w pliku w��czonym (include) zwraca pozycj� w tym pliku.
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
<term>PHP_VERSION</term>
<listitem>
<simpara>
- The string representation of the version of the PHP parser
- presently in use; e.g. '4.0.7-dev'.
+ �a�cuch reprezentuj�cy aktualnie u�ywan� wersj� parsera PHP, np.
+ '4.0.7-dev'.
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
<term>PHP_OS</term>
<listitem>
<simpara>
- The name of the operating system on which the PHP parser is
- executing;. Possible values may be :
+ Nazwa systemu operacyjnego, na kt�rym uruchomiony jest parser
+ PHP. Mo�liwe warto�ci to:
"AIX", "Darwin" (MacOS), "Linux", "SunOS", "WIN32", "WINNT".
- Note: other values may be available too.
+ Uwaga: inne warto�ci r�wnie� mog� by� dost�pne.
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
- <term>&true; (case-insensitive)</term>
+ <term>&true; (niewa�na wielko�� liter)</term>
<listitem>
<simpara>
- A &true; value (see the <type>boolean</type> type).
+ Warto�� &true; (zobacz: typ <type>boolean</type>).
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
- <term>&false; (case-insensitive)</term>
+ <term>&false; (niewa�na wielko�� liter)</term>
<listitem>
<simpara>
- A &false; value (see the <type>boolean</type> type).
+ Warto�� &false; (zobacz: typ<type>boolean</type>).
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
- <term>&null; (case-insensitive)</term>
+ <term>&null; (niewa�na wielko�� liter)</term>
<listitem>
<simpara>
- A &null; value (see the <type>null</type> type).
+ Warto�� &null; (zobacz: typ <type>null</type>).
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
<term>E_ERROR</term>
<listitem>
<simpara>
- Denotes an error other than a parsing error from which
- recovery is not possible.
+ Oznacza b��d inny ni� b��d przy parsowaniu (przetwarzaniu),
+ kt�rego naprawienie nie jest mo�liwe.
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
<term>E_WARNING</term>
<listitem>
<simpara>
- Denotes a condition where PHP knows something is wrong, but
- will continue anyway; these can be caught by the script
- itself. An example would be an invalid regexp in
+ Oznacza stan, w kt�rym PHP "wie", �e co� jest �le, ale
+ kontynuuje dzia�anie; b��dy takie mog� by� przechwycone przez sam
+ skrypt.
+ Przyk�adem mo�e by� nieprawid�owe wyra�enie regularne w funkcji
<function>ereg</function>.
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
<term>E_PARSE</term>
<listitem>
<simpara>
- The parser choked on invalid syntax in the script
- file. Recovery is not possible.
+ Parser stan�� przy nieprawid�owej sk�adni w skrypcie. Naprawa
+ b��du i kontynuacja nie jest mo�liwa.
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
<term>E_NOTICE</term>
<listitem>
<simpara>
- Something happened which may or may not be an error. Execution
- continues. Examples include using an unquoted string as an array
- index, or accessing a variable which has not been set.
+ Zdarzy�o si� co� co mo�e acz nie musi by� b��dem. PHP kontynuuje
+ dzia�anie. Przyk�adem mo�e by� u�ywanie niepodanego �a�cucha jako
+ indeksu w tablicy albo �adanie dost�pu do niezadeklarowanej
+ zmiennej.
</simpara>
</listitem>
</varlistentry>
-
+
<varlistentry>
<term>E_ALL</term>
<listitem>
<simpara>
- All of the E_* constants rolled into one. If used with
- <function>error_reporting</function>, will cause any and all
- problems noticed by PHP to be reported.
+ Wszystkie sta�e E_* w jednej. Je�li sta�a ta zostanie u�yta z
+ funkcj� <function>error_reporting</function>, spowoduje to, �e
+ jakiekolwiek problemy zauwa�one przez PHP b�d� zg�aszane przez
+ funkcj�.
</simpara>
</listitem>
</varlistentry>
@@ -247,28 +247,28 @@
</para>
<para>
- The <literal>E_*</literal> constants are typically used with the
- <function>error_reporting</function> function for setting the
- error reporting level. See all these constants at
- <link linkend="features.error-handling">Error handling</link>.
+ Sta�e <literal>E_*</literal> s� zwykle u�ywane z funkcj�
+ <function>error_reporting</function> aby ustawi� poziom zg�aszania
+ b��d�w. Zobacz wszystkie takie sta�e w rozdziale
+ <link linkend="features.error-handling">Obs�uga b��d�w</link>.
<example>
- <title>Using __FILE__ and __LINE__</title>
+ <title>U�ywanie __FILE__ i __LINE__</title>
<programlisting>
<?php
-function report_error($file, $line, $message)
+function report_error($plik, $linia, $komunikat)
{
- echo "An error occured in $file on line $line: $message.";
+ echo "Wyst�pi� b��d w $plik w linii $linia: $message.";
}
-report_error(__FILE__, __LINE__, "Something went wrong!");
+report_error(__FILE__, __LINE__, "Co� posz�o �le!");
?>
</programlisting>
</example>
</para>
</sect1>
</chapter>
-
+
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Index: phpdoc/pl/language/oop.xml
diff -u phpdoc/pl/language/oop.xml:1.1 phpdoc/pl/language/oop.xml:1.2
--- phpdoc/pl/language/oop.xml:1.1 Tue Oct 23 07:19:38 2001
+++ phpdoc/pl/language/oop.xml Tue Oct 30 07:31:02 2001
@@ -1,5 +1,5 @@
<?xml encoding="iso-8859-2"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<chapter id="language.oop">
<title>Klasy i Obiekty</title>
@@ -108,13 +108,11 @@
</programlisting>
</informalexample>
</note>
-<!-- ??? -->
<para>
- Classes are types, that is, they are blueprints for actual
- variables. You have to create a variable of the desired type with
- the <literal>new</literal> operator.
+ Klasy s� typami, kt�re s� w zasadzie tylko schematami dla w�a�ciwych
+ zmiennych. Zmienne po��danego typu musisz stworzy� korzystaj�c z operatora
+ <literal>new</literal>.
</para>
-<!-- ??? -->
<informalexample>
<programlisting role="php">
@@ -134,50 +132,45 @@
</para>
<para>
- Both, $cart and $another_cart, have functions add_item(),
- remove_item() and a variable items. These are distinct
- functions and variables. You can think of the objects as
- something similar to directories in a filesystem. In a
- filesystem you can have two different files README.TXT, as
- long as they are in different directories. Just like with
- directories where you'll have to type the full pathname in
- order to reach each file from the toplevel directory, you
- have to specify the complete name of the function you want
- to call: In PHP terms, the toplevel directory would be the
- global namespace, and the pathname separator would be ->.
- Thus, the names $cart->items and $another_cart->items
- name two different variables. Note that the variable is
- named $cart->items, not $cart->$items, that is, a
- variable name in PHP has only a single dollar sign.
+ I $koszyk i $inny_koszyk maj� funkcje dodaj_produkt(), usun_produkt() i
+ zmienne. S� to osobne funkcje i zmienne. Obiekty mog� by� postrzegane jako
+ katalogi w systemie plik�w. W systemie plik�w mo�esz mie� dwa r�ne pliki
+ README.TXT, ale tylko je�li istniej� w osobnych katalogach. Aby odczyta�
+ plik, b�d�c w g��wnym katalogu, musisz poda� pe�n� �cie�k� do tego pliku.
+ Tak samo jest przy obiektach: musisz poda� pe�n� nazw� funkcji, z kt�rej
+ chcesz skorzysta�. W terminologii PHP katalogiem g��wnym b�dzie globalna
+ przestrze� nazw a separatorem �cie�ki b�dzie ->. W zwi�zku z tym nazwy
+ $koszyk i $inny_koszyk zawieraj� zupe�nie inne zmienne. Zauwa�, �e zmienna
+ nazywa si� $koszyk->artykuly, a nie $koszyk->$artykuly, poniewa�
+ nazwa zmiennej mo�e zawiera� tylko jeden znak dolara.
</para>
<informalexample>
<programlisting role="php">
-// correct, single $
-$cart->items = array("10" => 1);
+// poprawnie, jeden $
+$koszyk->artykuly = array("10" => 1);
-// invalid, because $cart->$items becomes $cart->""
-$cart->$items = array("10" => 1);
+// niepoprawnie, poniwa� $koszyk->$artykuly zamienia si� na $koszyk->""
+$koszyk->$artykuly = array("10" => 1);
-// correct, but may or may not be what was intended:
-// $cart->$myvar becomes $cart->items
-$myvar = 'items';
-$cart->$myvar = array("10" => 1);
+// poprawnie, ale mo�e (ale nie musi) nie by� tym, co zamierzali�my:
+// $koszyk->$zmienna staje si� $koszyk->artykuly
+$zmienna = 'artykuly';
+$koszyk->$zmienna = array("10" => 1);
</programlisting>
</informalexample>
<para>
- Within a class definition, you do not know under which name the object will
- be accessible in your program: At the time the Cart class was
- written, it was unknown that the object will be named $cart or
- $another_cart later. Thus, you cannot write $cart->items within
- the Cart class itself. Instead, in order to be able to access it's own
- functions and variables from within a class, one can use the
- pseudo-variable $this which can be read as 'my own' or
- 'current object'. Thus, '$this->items[$artnr] += $num' can
- be read as 'add $num to the $artnr counter of my own items
- array' or 'add $num to the $artnr counter of the items array
- within the current object'.
+ Wewn�trz definicji klasy, nie wiesz pod jak� nazw� obiekt b�dzie dost�pny
+ dla twojego programu: w momencie pisania klasy Koszyk, nie by�o wiadomo,
+ �e obiekty b�d� si� nazywa� $koszyk lub $inny_koszyk. W zwi�zku z tym nie
+ mo�esz napisa� $koszyk->artykuly wewn�trz klasy Koszyk. Zamiast tego,
+ aby uzyska� dost�p do funkcji i zmiennych zawartych w klasie, mo�na u�y�
+ pseudo-zmiennej $this, kt�ra mo�e by� odczytana jako 'moje w�asne' lub
+ 'bie��cy obiekt'. A wi�c '$this->artykuly[$nrart] += $liczba' mo�e by�
+ odczytane jako 'dodaj $liczba do licznika $nrart z mojej w�asnej tablicy
+ artykuly' lub 'dodaj $liczba do licznika $nrartz tablicy artykuly zawartej
+ w bie��cym obiekcie'.
</para>
</sect1>
@@ -185,123 +178,122 @@
<title><literal>extends</literal></title>
<para>
- Often you need classes with similar variables and functions
- to another existing class. In fact, it is good practice to
- define a generic class which can be used in all your
- projects and adapt this class for the needs of each of your
- specific projects. To facilitate this, classes can be
- extensions of other classes. The extended or derived class
- has all variables and functions of the base class (this is
- called 'inheritance' despite the fact that nobody died) and what
- you add in the extended definition. It is not possible to
- substract from a class, that is, to undefine any existing
- functions or variables. An extended class is always dependent
- on a single base class, that is, multiple inheritance is
- not supported. Classes are extended using the keyword 'extends'.
+ Bardzo cz�sto zachodzi potrzeba stworzenia klasy o funkcjach i zmiennych
+ podobnych do ju� istniej�cej klasy. Zasadniczo dobrze jest stworzy�
+ szablonow� klas�, kt�ra mo�e by� u�yta we wszystkich twoich projektach i
+ przystosowywa� j� do specyficznych potrzeb twojego projektu. Aby u�atwi�
+ ten proces, klasy mog� by� rozszerzeniami innych klas. Rozszerzone, lub
+ m�wi�c inaczej 'dziedziczone', klasy maj� wszystkie zmienne i funkcje
+ klasy podstawowej (nazywa si� to dziedziczeniem, mimo �e nikt nie
+ umar�) oraz to co do niej doda�e� w definicji rozszerzenia. Nie mo�na
+ odj�� pewnych rzeczy z klasy podstawowej, czyli oddefiniowa� istniej�cych
+ w klasie podstawowej funkcji i zmiennych. Rozszerzona klasa jest zawsze
+ zale�na od jednej klasy bazowej - dziedziczenie wielokrotne nie jest
+ obs�ugiwane. Klasy mo�na rozszerzy� u�ywaj�c s�owa kluczowego 'extends'.
</para>
<informalexample>
<programlisting role="php">
-class Named_Cart extends Cart
+class Nazwany_Koszyk extends Koszyk
{
- var $owner;
+ var $wlasciciel;
- function set_owner ($name)
+ function ustaw_wlasciciela ($nazwa)
{
- $this->owner = $name;
+ $this->wlasciciel = $nazwa;
}
}
</programlisting>
</informalexample>
<para>
- This defines a class Named_Cart that has all variables and
- functions of Cart plus an additional variable $owner and an
- additional function set_owner(). You create a named cart the usual
- way and can now set and get the carts owner. You can still use
- normal cart functions on named carts:
+ Definiuje to klas� Nazwany_Koszyk, kt�ry ma wszystkie zmienne i funkcje
+ klasy Koszyk plus dodatkowa zmienna $wlasciciel i dodatkowa funkcja
+ ustaw_wlasciciela(). Nazwany koszyk tworzy si� normalnym sposobem.
+ Mo�esz teraz ustawia� i pobiera� nazw� w�a�ciciela koszyka. Ca�y czas
+ mo�esz u�ywa� zwyk�ych funkcji koszyka dla nazwanego koszyka:
</para>
<informalexample>
<programlisting role="php">
-$ncart = new Named_Cart; // Create a named cart
-$ncart->set_owner("kris"); // Name that cart
-print $ncart->owner; // print the cart owners name
-$ncart->add_item("10", 1); // (inherited functionality from cart)
+$nkoszyk = new Nazwany_Koszyk; // Stw�rz nazwany koszyk
+$nkoszyk->ustaw_wlasciciela("kris"); // Nazwij koszyk
+print $nkoszyk->wlasciciel; // Wy�wietl w�a�ciciela koszyka
+$nkoszyk->dodaj_przedmiot("10", 1); // (funkcjonalno�� odziedziczona z
+ // koszyka)
</programlisting>
</informalexample>
</sect1>
<sect1 id="language.oop.constructor">
- <title><literal>Constructors</literal></title>
+ <title><literal>Konstruktory</literal></title>
<caution>
<simpara>
- In PHP 3 and PHP 4 constructors behave differently. The PHP 4
- semantics are strongly preferred.
+ Konstruktory zachowuj� si� inaczej w PHP 3 i w PHP 4. Semantyka PHP 4
+ jest mocno zalecana.
</simpara>
</caution>
<para>
- Constructors are functions in a class that are automatically
- called when you create a new instance of a class with
- <literal>new</literal>. In PHP 3, a
- function becomes a constructor when it has the same name as
- the class. In PHP 4, a function becomes a constructor, when
- it has the same name as the class it is defined in - the
- difference is subtle, but crucial (see below).
+ Konstruktory s� funkcjami klasy, kt�re s� automatycznie wywo�ywane przy
+ tworzeniu nowej instancji klasy korzystaj�c z operatora
+ <literal>new</literal>. W PHP 3 funkcja staje si� konstruktorem kiedy ma
+ tak� sam� nazw� jak klasa. W PHP 4 funkcja staje si� konstruktorem, kiedy
+ ma tak� sam� nazw� jak klasa, w kt�rej ta funkcja zosta�a zdefiniowana -
+ r�nica jest subtelna, ale bardzo wa�na (zobacz poni�ej)
</para>
<informalexample>
<programlisting role="php">
-// Works in PHP 3 and PHP 4.
-class Auto_Cart extends Cart
+// Dzia�a w PHP 3 i PHP 4.
+class Auto_Koszyk extends Koszyk
{
- function Auto_Cart()
+ function Auto_Koszyk()
{
- $this->add_item ("10", 1);
+ $this->dodaj_artykul ("10", 1);
}
}
</programlisting>
</informalexample>
<para>
- This defines a class Auto_Cart that is a Cart plus a constructor
- which initializes the cart with one item of article number "10"
- each time a new Auto_Cart is being made with "new". Constructors
- can take arguments and these arguments can be optional, which
- makes them much more useful. To be able to still use the class
- without parameters, all parameters to constructors should be
- made optional by providing default values.
+ Ten kod definiuj� klas� Auto_Koszyk, kt�ry jest klas� Koszyk pluc
+ konstruktor, kt�ry inicjalizuje w�zek z jednym artyku�em "10" za ka�dym
+ razem, kiedy Auto_Koszyk jest tworzony operatorem "new". Konstruktory mog�
+ pobiera� argumenty i te argumenty mog� by� opcjonalne, przez co s� jeszcze
+ bardziej u�yteczne. Aby w dalszym ci�gu m�c u�ywa� klasy bez parametr�w,
+ wszystkie parametry konstruktora powinny sta� si� opcjonalne przez dodanie
+ domy�lnych warto�ci.
</para>
<informalexample>
<programlisting role="php">
-// Works in PHP 3 and PHP 4.
-class Constructor_Cart extends Cart
+// Dzia�a w PHP 3 i PHP 4.
+class Kontruktor_Koszyk extends Koszyk
{
- function Constructor_Cart($item = "10", $num = 1)
+ function Konstruktor_Koszyk($artykul = "10", $ilosc = 1)
{
- $this->add_item ($item, $num);
+ $this->dodaj_artykul ($artykul, $ilosc);
}
}
-// Shop the same old boring stuff.
+// Kup te same nudne rzeczy...
-$default_cart = new Constructor_Cart;
+$zwykly_koszyk = new Konstruktor_Koszyk;
-// Shop for real...
+// Czas na prawdziwe zakupy...
-$different_cart = new Constructor_Cart("20", 17);
+$inny_koszyk = new Konstruktor_Koszyk("20", 17);
</programlisting>
</informalexample>
<caution>
<simpara>
- In PHP 3, derived classes and constructors have a number of
- limitations. The following examples should be read carefully
- to understand these limitations.
+ W PHP 3, dziedziczone klasy i konstruktory maj� wiele ogranicze�.
+ Poni�sze przyk�ady powinny by� dok�adnie przeczytane w celu zrozumienia
+ tych ogranicze�.
</simpara>
</caution>
@@ -311,7 +303,7 @@
{
function A()
{
- echo "I am the constructor of A.<br>\n";
+ echo "Jestem konstruktorem klasy A.<br>\n";
}
}
@@ -319,27 +311,27 @@
{
function C()
{
- echo "I am a regular function.<br>\n";
+ echo "Zwyk�a funkcja.<br>\n";
}
}
-// no constructor is being called in PHP 3.
+// W PHP 3 nie zostanie wywo�any �aden konstruktor.
$b = new B;
</programlisting>
</informalexample>
<para>
- In PHP 3, no constructor is being called in the above example.
- The rule in PHP 3 is: 'A constructor is a function of the same
- name as the class.'. The name of the class is B, and there is
- no function called B() in class B. Nothing happens.
+ W PHP 3 w powy�szym przyk�adzie nie b�dzie wywo�any �aden konstruktor.
+ Zasad� PHP 3 jest: 'Konstruktor to funkcja o takiej samej nazwie jak
+ klasa'. Nazw� klasy jest B, a w klasie B nie ma funkcji o nazwie B(). Nic
+ si� nie dzieje.
</para>
<para>
- This is fixed in PHP 4 by introducing another rule: If a class
- has no constructor, the constructor of the base class is being
- called, if it exists. The above example would have printed
- 'I am the constructor of A.<br>' in PHP 4.
+ Zosta�o to poprawione w PHP 4 przez wprowadzenie innej zasady: je�li klasa
+ nie ma konstruktora, u�ywany jest konstruktor klasy bazowej, je�li taki
+ istnieje. W PHP 4 powy�szy przyk�ad wy�wietli 'Jestem konstruktorem klasy
+ A.<br>'.
</para>
<informalexample>
@@ -348,13 +340,13 @@
{
function A()
{
- echo "I am the constructor of A.<br>\n";
+ echo "Jestem konstruktorem klasy A.<br>\n";
}
function B()
{
- echo "I am a regular function named B in class A.<br>\n";
- echo "I am not a constructor in A.<br>\n";
+ echo "Jestem zwyk�� funkcj� o nazwie B w klasie A.<br>\n";
+ echo "Nie jestem konstruktorem w klasie A.<br>\n";
}
}
@@ -362,53 +354,51 @@
{
function C()
{
- echo "I am a regular function.<br>\n";
+ echo "Jestem zwyk�� funkcj�.<br>\n";
}
}
-// This will call B() as a constructor.
+// Wywo�a to B() jako konstruktor.
$b = new B;
</programlisting>
</informalexample>
<para>
- In PHP 3, the function B() in class A will suddenly become a
- constructor in class B, although it was never intended to be.
- The rule in PHP 3 is: 'A constructor is a function of the same
- name as the class.'. PHP 3 does not care if the function is
- being defined in class B, or if it has been inherited.
+ W PHP 3, funkcja B() z klasy A niespodziewanie stanie si� konstruktorem w
+ klasie B, pomimo �e wcale nie mia�a nim by�. Zasad� PHP 3 jest:
+ 'Konstruktor to funkcja o takiej samej nazwie co klasa'. PHP 3 nie
+ obchodzi czy funkcja zosta�a zdefiniowana w klasie B czy zosta�a
+ odziedziczona.
</para>
<para>
- This is fixed in PHP 4 by modifying the rule to: 'A constructor
- is a function of the same name as the class it is being defined
- in.'. Thus in PHP 4, the class B would have no constructor function
- of its own and the constructor of the base class would have been
- called, printing 'I am the constructor of A.<br>'.
+ Zosta�o to poprawione w PHP 4 przez modyfikacj� tej zasady do:
+ 'Konstruktor to funkcja o tej samej nazwie co klasa w kt�rej zosta�a
+ zdefiniowana'. W zwi�zku z tym w PHP 4 clasa B nie mia�aby w�asnego
+ konstruktora. Wywo�any by�by tylko konstruktor klasy bazowej, wy�wietlaj�c
+ 'Jestem konstruktorem klasy A.<br>'.
</para>
<caution>
<simpara>
- Neither PHP 3 nor PHP 4 call constructors of the base class
- automatically from a constructor of a derived class. It is
- your responsibility to propagate the call to constructors
- upstream where appropriate.
+ Ani PHP 3 ani PHP 4 nie wywo�a automatycznie konstruktora klasy bazowej z
+ kontruktora klasy pochodnej. Twoim zadaniem jest propagacja wywo�a�
+ konstruktor�w klas nadrz�dnych, je�li to konieczne.
</simpara>
</caution>
<note>
<simpara>
- There are no destructors in PHP 3 or PHP 4. You may use
- <function>register_shutdown_function</function> instead
- to simulate most effects of destructors.
+ Ani w PHP 3 ani w PHP 4 nie ma destruktor�w. Zamiast tego mo�esz u�y�
+ <function>register_shutdown_function</function> aby symulowa� dzia�anie
+ destruktor�w.
</simpara>
</note>
<para>
- Destructors are functions that are called automatically
- when an object is destroyed, either with <function>unset</function>
- or by simply going out of scope. There are no destructors
- in PHP.
+ Destruktory s� funkcjami, kt�re s� wywo�ywanie automatycznie kiedy obiekty
+ s� niszczone albo przez u�ycie <function>unset</function> albo przez
+ wyj�cie z zasi�gu. W PHP nie ma destruktor�w.
</para>
</sect1>
@@ -417,82 +407,76 @@
<caution>
<simpara>
- The following is valid for PHP 4 only.
+ Poni�sze dotyczy tylko PHP 4.
</simpara>
</caution>
<para>
- Sometimes it is useful to refer to functions and variables
- in base classes or to refer to functions in classes that
- have not yet any instances. The :: operator is being used
- for this.
+ Czasami dobrze jest odnosi� si� do funkcji i zmiennych w klasie bazowej
+ lub odnosi� si� do funkcji i klas kt�re nie maj� jeszcze instancji. S�u�y
+ do tego operator ::.
</para>
<informalexample>
<programlisting role="php">
class A
{
- function example()
+ function przyklad()
{
- echo "I am the original function A::example().<br>\n";
+ echo "Jestem orginaln� funkcj� A::przyklad().<br>\n";
}
}
class B extends A
{
- function example()
+ function przyklad()
{
- echo "I am the redefined function B::example().<br>\n";
- A::example();
+ echo "Jestem przedefiniowan� funkcj� B::przyklad().<br>\n";
+ A::przyklad();
}
}
-// there is no object of class A.
-// this will print
-// I am the original function A::example().<br>
-A::example();
+// nie ma obiektu klasy A.
+// poni�sze wy�wietli
+// Jestem orginaln� funkcj� A::przyklad().<br>
+A::przyklad();
-// create an object of class B.
+// stw�rz nowy obiekt klasy B.
$b = new B;
-// this will print
-// I am the redefined function B::example().<br>
-// I am the original function A::example().<br>
-$b->example();
+// poni�sze wy�wietli
+// Jestem przedefiniowan� funkcj� B::przyklad().<br>
+// Jestem orginaln� funkcj� A::przyklad().<br>
+$b->przyklad();
</programlisting>
</informalexample>
<para>
- The above example calls the function example() in
- class A, but there is no object of class A, so that
- we cannot write $a->example() or similar. Instead we
- call example() as a 'class function', that is, as a
- function of the class itself, not any object of that
- class.
+ Powy�szy przek�ad wywo�uje funkcj� przyklad() z klasy A, ale nie tworz�c
+ obiektu tej klasy, przez co nie mo�emy napisa� nic w stylu $a->przyklad().
+ Zamiast tego mo�emy wywo�a� przyklad() jako 'funkcj� klasy', czyli jako
+ funkcj� tylko klasy, nie �adnego obiektu tej klasy.
</para>
<para>
- There are class functions, but there are no class variables.
- In fact, there is no object at all at the time of the call.
- Thus, a class function may not use any object variables (but
- it can use local and global variables), and it may no use
- $this at all.
+ Istniej� funkcje klasy, ale nie ma zmiennych klasy. Faktycznie w czasie
+ wykonania nie ma �adnego obiektu. W zwi�zku z tym funkcje klasy nie mog�
+ u�ywa� �adnych zmiennych obiektu (ale mog� u�ywa� zmiennych lokalnych i
+ globalnych), ani w og�le $this.
</para>
<para>
- In the above example, class B redefines the function example().
- The original definition in class A is shadowed
- and no longer available, unless you are refering specifically
- to the implementation of example() in class A using the
- ::-operator. Write A::example() to do this (in fact, you
- should be writing parent::example(), as shown in the next
- section).
+ W powy�szym przyk�adzie, klasa B przedefiniowuje funkcj� przyklad().
+ Orginalna definicja z klasy A jest zas�oni�ta i niedost�pna, chyba �e
+ odwo�asz si� do konkretnej implementacji poprzez operator ::. Aby to
+ zrobi�, napisz A::przyklad() (powiniene� jednak u�y� parent::przyklad(),
+ tak jak to pokazano w nast�pnej cz�ci).
</para>
<para>
- In this context, there is a current object and it may
- have object variables. Thus, when used from WITHIN an
- object function, you may use $this and object variables.
+ W tym kontek�cie, istnieje bie��cy obiekt i kt�ry ma zmienne obiektu. W
+ zwi�zu z tym je�li funkcja jest u�yta Z WEWN�TRZ funkcji obiektu, mo�esz
+ u�ywa� $this i zmiennych obiektu.
</para>
</sect1>
@@ -501,91 +485,85 @@
<title><literal>parent</literal></title>
<para>
- You may find yourself writing code that refers to
- variables and functions in base classes. This is
- particularly true if your derived class is a refinement
- or specialisation of code in your base class.
+ Mo�e si� zdarzy�, �e b�dziesz pisa� kod, kt�ry odnosi si� do funkcji i
+ zmiennych klasy bazowej. Jest to mo�liwe je�li twoja klasa pochodna jest
+ u�ci�leniem lub specjalizacj� klasy bazowej.
</para>
<para>
- Instead of using the literal name of the base class in your
- code, you should be using the special name
- <literal>parent</literal>, which refers to the name of your
- base class as given in the <literal>extends</literal>
- declation of your class. By doing this, you avoid using the
- name of your base class in more than one place. Should
- your inheritance tree change during implementation, the
- change is easily made by simply changing the
- <literal>extends</literal> declaration of your class.
+ Zamiast jawnego podawania nazwy klasy bazowej w kodzie, powiniene� u�y�
+ specjalnej nazwy <literal>parent</literal>, kt�ra odnosi si� do nazwy klasy
+ bazowej podanej przy <literal>extends</literal> podczas deklaracji twojej
+ klasy. Robi�c to, unikasz u�ycia nazwy klasy bazowej w wi�cej ni� jednym
+ miejscu. Je�li twoje drzewo dziedziczenia zmieni�oby si� podczas
+ implementacji, zmiana b�dzie wymaga�a poprawki tylko w jednym miejscu -
+ przy s�owie kluczowym <literal>extends</literal> w deklaracji klasy.
</para>
<informalexample>
<programlisting role="php">
class A
{
- function example()
+ function przyklad()
{
- echo "I am A::example() and provide basic functionality.<br>\n";
+ echo "Jestem A::przyklad() I dostarczam podstawow� funkcjonalno��.<br>\n";
}
}
class B extends A
{
- function example()
+ function przyklad()
{
- echo "I am B::example() and provide additional functionality.<br>\n";
- parent::example();
+ echo "Jestem B::przyklad() i dostarczam dodatkow� funkcjonalno��.<br>\n";
+ parent::przyklad();
}
}
$b = new B;
-// This will call B::example(), which will in turn call A::example().
-$b->example();
+// Wywo�a to B::przyklad(), kt�ry z kolei wywo�a A::przyklad().
+$b->przyklad();
</programlisting>
</informalexample>
</sect1>
<sect1 id="language.oop.serialization">
- <title>Serializing objects - objects in sessions</title>
+ <title>Serializacja obiekt�w - obiekty w sesjach</title>
<note>
<simpara>
- In PHP 3, objects will lose their class association
- throughout the process of serialization and unserialization.
- The resulting variable is of type object, but has no class
- and no methods, thus it is pretty useless (it has become
- just like an array with a funny syntax).
+ W PHP 3 obiekty trac� powi�zania mi�dzy klasami w czasie procesu
+ serializacji i odserializacji. Wynikowa zmienna b�dzie typu obiekt, ale
+ bez klasy i bez metod, a wi�c w zasadzie bezu�yteczn� (zostanie poprostu
+ zmienn� ze �mieszn� sk�adni�).
</simpara>
</note>
<caution>
<simpara>
- The following information is valid for PHP 4 only.
+ Poni�sze informacje dotycz� tylko PHP 4.
</simpara>
</caution>
<para>
- <function>serialize</function> returns a string containing a
- byte-stream representation of any value that can be stored in
- PHP. <function>unserialize</function> can use this string to
- recreate the original variable values. Using serialize to
- save an object will save all variables in an object. The
- functions in an object will not be saved, only the name of
- the class.
+ <function>serialize</function> zwraca string b�d�cy reprezentacj� dowolnej
+ warto�ci, kt�ra mo�e by� przechowywana przez PHP.
+ <function>unserialize</function> mo�e u�y� tego stringu aby odtworzy�
+ orginalne warto�ci zmiennej. U�ycie serializacji do zapisania obiektu
+ zachowa wszystkie zmienne z obiektu. Zapisane nie b�d� funkcje z obiektu, a
+ jedynie nazwa klasy.
</para>
<para>
- In order to be able to <function>unserialize</function> an
- object, the class of that object needs to be defined. That
- is, if you have an object $a of class A on page1.php and
- serialize this, you'll get a string that refers to class A
- and contains all values of variabled contained in $a. If
- you want to be able to unserialize this on page2.php,
- recreating $a of class A, the definition of class A must
- be present in page2.php. This can be done for example
- by storing the class defintion of class A in an include
- file and including this file in both page1.php and page2.php.
+ Aby istnia�a mo�liwo�� u�ycia funkcji <function>unserialize</function> do
+ odzyskania obiektu, musi by� zdefiniowana klasa tego obiektu. Oznacza to,
+ �e je�li obiekt $a klasy A istnieje na page1.php i zserializujesz go,
+ otrzymasz string, kt�ry odnosi si� do klasy A i zawiera warto�ci wszystkich
+ zmiennych zawartych w $a. Je�li chcesz, aby istnia�a mo�liwo��
+ odserializacji tego obiektu na page2.php, na page2.php musi istnie�
+ definicja klasy A. Mo�na to zrobi� na przyk�ad przez przechowywanie
+ definicji klasy A w zewn�trznym pliku includowanym przez page1.php i
+ page2.php.
</para>
<informalexample>
@@ -593,11 +571,11 @@
classa.inc:
class A
{
- var $one = 1;
+ var $jeden = 1;
- function show_one()
+ function pokaz_jeden()
{
- echo $this->one;
+ echo $this->jeden;
}
}
@@ -606,115 +584,110 @@
$a = new A;
$s = serialize($a);
- // store $s somewhere where page2.php can find it.
+ // przechowaj $s gdzie�, gdzie page2.php b�dzie mog�a go znale��
$fp = fopen("store", "w");
fputs($fp, $s);
fclose($fp);
page2.php:
- // this is needed for the unserialize to work properly.
+ // to jest niezb�dne aby funkcja unserialize dzia�a�a prawid�owo.
include("classa.inc");
$s = implode("", @file("store"));
$a = unserialize($s);
- // now use the function show_one() of the $a object.
- $a->show_one();
+ // teraz u�yj funkcji pokaz_jeden z obiektu $a.
+ $a->pokaz_jeden();
</programlisting>
</informalexample>
<para>
- If you are using sessions and use <function>session_register</function>
- to register objects, these objects are serialized automatically
- at the end of each PHP page, and are unserialized automatically on
- each of the following pages. This basically means that these objects
- can show up on any of your pages once they become part of your
- session.
+ Je�li u�ywasz sesji i <function>session_register</function> do rejestracji
+ obiekt�w, te obiekty s� serializowane automatycznie na ko�cu ka�dej strony
+ PHP i odserializowane automatycznie na ka�dej z nast�pnych stron.
+ Zasadniczo znaczy to, �e te obiekty mog� pokaza� si� na dowolnej z twoich
+ stron je�li tylko stan� si� cz�ci� twojej sesji.
</para>
<para>
- It is strongly recommended that you include the class
- definitions of all such registered objects on all of your
- pages, even if you do not actually use these classes on all
- of your pages. If you don't and an object is being
- unserialized without its class definition being present, it
- will lose its class association and become an object of class
- <literal>stdClass</literal> without any functions available
- at all, that is, it will become quite useless.
+ Mocno zalecane jest includowanie definicji klas wszystkich zarejestrowanych
+ obiekt�w na wszystkich twoich stronach, nawet je�li nie u�ywasz tych
+ zmiennych na twoich stronach. Je�li tego nie zrobisz a obiekty zostan�
+ odserializowane bez definicji klasy, powi�zania klasowe zostan� utracone a
+ obiek stanie si� obiektem klasy <literal>stdClass</literal> bez �adnych
+ dost�pnych funkcji, a wi�c b�dzie ca�kiem bezu�yteczny.
</para>
<para>
- So if in the example above $a became part of a session by
- running <literal>session_register("a")</literal>, you should
- include the file <literal>classa.inc</literal> on all of your
- pages, not only page1.php and page2.php.
+ A wi�c je�li w powy�szym przyk�adzie $a stanie si� cz�ci� sesji przez
+ wywo�anie <literal>session_register("a")</literal>, powiniene� includowa�
+ plik <literal>classa.inc</literal> na wszystkich stronach, nie tylko
+ page1.php i page2.php.
</para>
</sect1>
<sect1 id="language.oop.magic-functions">
- <title>The magic functions <literal>__sleep</literal> and
<literal>__wakeup</literal></title>
+ <title>Magiczne funkcje <literal>__sleep</literal> i
+<literal>__wakeup</literal></title>
<para>
- <function>serialize</function> checks if your class has a function with
- the magic name <literal>__sleep</literal>. If so, that function is
- being run prior to any serialization. It can clean up the object
- and is supposed to return an array with the names of all variables
- of that object that should be serialized.
+ <function>serialize</function> sprawdza, czy twoja klasa zawiera funkcj� o
+ magicznej nazwie <literal>__sleep</literal>. Je�li tak, ta funkcja jest
+ wywo�ywana przed ka�d� serializacj�. Mo�e ona czy�ci� obiekt i powinna
+ zwraca� tablic� z nazwami wszystkich zmiennych obiektu, kt�re powinny by�
+ serializowane.
</para>
<para>
- The intended use of <literal>__sleep</literal> is to close any
- database connections that object may have, committing pending
- data or perform similar cleanup tasks. Also, the function is
- useful if you have very large objects which need not be
- saved completely.
+ Za�o�onym u�yciem <literal>__sleep</literal> jest zamkni�cie wszystkich
+ po��cze� do baz danych, kt�re obiekt mo�e utrzymywa�, zatwierdzenie
+ wszystkich oczekuj�cych danych lub wykonanie innych podobnych czynno�ci
+ czyszcz�cych. Funkcja ta jest tak�e przydatna je�li masz bardzo du�e
+ obiekty, kt�re nie musz� by� zachowane w ca�o�ci.
</para>
<para>
- Conversely, <function>unserialize</function> checks for the
- presence of a function with the magic name
- <literal>__wakeup</literal>. If present, this function can
- reconstruct any ressources that object may have.
+ Analogicznie, <function>unserialize</function> sprawdza czy istnieje
+ funkcja o magicznej nazwie <literal>__wakeup</literal>. Je�li tak, funkcja
+ mo�e rekonstruowa� dowolne zasoby kt�re obiekt mo�e posiada�.
</para>
<para>
- The intended use of <literal>__wakeup</literal> is to
- reestablish any database connections that may have been lost
- during serialization and perform other reinitialization
- tasks.
+ Za�o�onym u�yciem <literal>__wakeup</literal> jest odnowienie po��cze� z
+ bazami danych, kt�re mog�y zostac utracone w procesie serializacji, oraz
+ wykonanie innych czynno�ci odbudowuj�cych obiekt.
</para>
</sect1>
<sect1 id="language.oop.newref">
- <title>References inside the constructor</title>
+ <title>Referencje wewn�trz konstruktora</title>
<para>
- Creating references within the constructor can lead to confusing
- results. This tutorial-like section helps you to avoid problems.
+ Tworzenie referencji wewn�trz konstruktora mo�e prowadzi� do dziwnych
+ efekt�w. Ten rozdzia� ma pom�c w unikaniu takich problem�w.
<informalexample>
<programlisting role="php">
class Foo
{
- function Foo($name)
+ function Foo($nazwa)
{
- // create a reference inside the global array $globalref
+ // stworz referencje wewnatrz globalnej tablicy $globalref
global $globalref;
$globalref[] = &$this;
- // set name to passed value
- $this->setName($name);
- // and put it out
- $this->echoName();
+ // ustaw nazw� na przekazan� warto��
+ $this->ustawNazwe($nazwa);
+ // i wy�wietl j�
+ $this->wyswietlNazwe();
}
- function echoName()
+ function wyswietlNazwe()
{
- echo "<br>",$this->name;
+ echo "<br>",$this->nazwa;
}
- function setName($name)
+ function ustawNazwe($nazwa)
{
- $this->name = $name;
+ $this->nazwa = $nazwa;
}
}
</programlisting>
@@ -722,86 +695,87 @@
</para>
<para>
- Let us check out if there is a difference between
- <varname>$bar1</varname> which has been created using
- the copy <literal>=</literal> operator and
- <varname>$bar2</varname> which has been created using
- the reference <literal>=&</literal> operator...
+ Sprawd�my, czy jest jaka� r�nica pomi�dzy
+ <varname>$bar1</varname>, kt�ry jest tworzony przy pomocy operatora
+ przypisania <literal>=</literal>, a <varname>$bar2</varname>, kt�ry zosta�
+ stworzony u�ywaj�c operatora referencji <literal>=&</literal>...
<informalexample>
<programlisting role="php">
-$bar1 = new Foo('set in constructor');
-$bar1->echoName();
-$globalref[0]->echoName();
-
-/* output:
-set in constructor
-set in constructor
-set in constructor */
-
-$bar2 =& new Foo('set in constructor');
-$bar2->echoName();
-$globalref[1]->echoName();
-
-/* output:
-set in constructor
-set in constructor
-set in constructor */
+$bar1 = new Foo('ustawione w konstruktorze');
+$bar1->wyswietlNazwe();
+$globalref[0]->wyswietlNazwe();
+
+/* wyj�cie:
+ustawione w konstruktorze
+ustawione w konstruktorze
+ustawione w konstruktorze */
+
+$bar2 =& new Foo('ustawione w konstruktorze');
+$bar2->wyswietlNazwe();
+$globalref[1]->wyswietlNazwe();
+
+/* wyj�cie:
+ustawione w konstruktorze
+ustawione w konstruktorze
+ustawione w konstruktorze */
</programlisting>
</informalexample>
</para>
<para>
- Apparently there is no difference, but in fact there is a
- very significant one: <varname>$bar1</varname> and
- <varname>$globalref[0]</varname> are _NOT_ referenced, they
- are NOT the same variable. This is because "new" does not
- return a reference by default, instead it returns a copy.
+ Wydaje si�, �e nie ma �adnej r�nicy, ale na prawd� jest jedna, i to
+ bardzo istotna: <varname>$bar1</varname> i
+ <varname>$globalref[0]</varname> <emphasis>NIE</emphasis> s� referencjami,
+ <emphasis>NIE</emphasis> s� t� sam� zmienna. Dzieje si� tak, poniewa�
+ "new" nie zwraca domy�lnie referencji, ale kopi�.
<note>
<simpara>
- There is no performance loss (since PHP 4 and up use reference
- counting) returning copies instead of references. On the
- contrary it is most often better to simply work with copies
- instead of references, because creating references takes some
- time where creating copies virtually takes no time (unless none
- of them is a large array or object and one of them gets changed
- and the other(s) one(s) subsequently, then it would be wise to
- use references to change them all concurrently).
+ Zwracanie kopii zamiast referencji nie powoduje utraty wydajno�ci (od
+ PHP 4 u�ywane jest zliczanie referencji). Jednak�e zazwyczaj lepiej jest
+ pracowa� poprostu z kopiami zamiast referencji, poniewa� tworzenie
+ referencji zabiera troch� czasu, podczas gdy tworzenie kopii obiekt�w
+ teoretycznie w og�le nie zabiera czasu (chyba �e kt�ra� z tych zmiennych
+ jest du�� tablic� lub obiektem i jedno z nich ulega zmianie, po czym tej
+ samej zmianie ulegaj� pozosta�e zmienne; wtedy lepiej jest u�y�
+ referencji do zmieniania ich r�wnolegle).
</simpara>
</note>
- To prove what is written above let us watch the code below.
+ Aby udowodni� to, co zosta�o zapisane powy�ej, przyjrzyjmy si� poni�szemu
+ programowi.
<informalexample>
<programlisting role="php">
-// now we will change the name. what do you expect?
-// you could expect that both $bar1 and $globalref[0] change their names...
-$bar1->setName('set from outside');
-
-// as mentioned before this is not the case.
-$bar1->echoName();
-$globalref[0]->echoName();
-
-/* output:
-set from outside
-set in constructor */
-
-// let us see what is different with $bar2 and $globalref[1]
-$bar2->setName('set from outside');
-
-// luckily they are not only equal, they are the same variable
-// thus $bar2->name and $globalref[1]->name are the same too
-$bar2->echoName();
-$globalref[1]->echoName();
-
-/* output:
-set from outside
-set from outside */
+// teraz zmienimy nazw�. czego si� spodziewasz?
+// mo�esz si� spodziewa�, �e i $bar1 i $globalref[0] zmieni� swoje nazwy...
+$bar1->ustawNazwe('ustawiona z zewn�trz');
+
+// jak napisano powy�ej, nic takiego si� nie stanie
+$bar1->wyswietlNazwe();
+$globalref[0]->wyswietlNazwe();
+
+/* wyj�cie:
+ustawiona z zewn�trz
+ustawiona w konstruktorze */
+
+// zobaczmy co si� dzieje z $bar2 i $globalref[1]
+$bar2->ustawNazwe('ustawiona z zewn�trz');
+
+// na szcz�cie ta zmienna nie zachowuje si� jak ta z poprzedniego przypadku
+// s� to te same zmienne, z wi�c $bar2->nazwa i $globalref[1]->nazwa s� tak�e
+// tymi samymi zmiennymi
+$bar2->wyswietlNazwe();
+$globalref[1]->wyswietlNazwe();
+
+/* wyj�cie:
+ustawiona z zewn�trz
+ustawiona z zewn�trz */
</programlisting>
</informalexample>
</para>
<para>
- Another final example, try to understand it.
+ Ustatni przyk�ad. Postaraj si� go zrozumie�/
<informalexample>
<programlisting role="php">
@@ -809,19 +783,19 @@
{
function A($i)
{
- $this->value = $i;
- // try to figure out why we do not need a reference here
+ $this->wartosc = $i;
+ // domy�l si� dlaczego nie potrzebujemy tutaj referencji
$this->b = new B($this);
}
- function createRef()
+ function stworzRef()
{
$this->c = new B($this);
}
- function echoValue()
+ function wyswietlWartosc()
{
- echo "<br>","class ",get_class($this),': ',$this->value;
+ echo "<br>","klasa ",get_class($this),': ',$this->value;
}
}
@@ -833,35 +807,34 @@
$this->a = &$a;
}
- function echoValue()
+ function wyswietlWartosc()
{
- echo "<br>","class ",get_class($this),': ',$this->a->value;
+ echo "<br>","klasa ",get_class($this),': ',$this->a->value;
}
}
-
-// try to undestand why using a simple copy here would yield
-// in an undesired result in the *-marked line
+// spr�buj zrozumie� dlaczego u�ycie tu prostego kopiowania mo�e powodowa�
+// nieporz�dany efekt w linii uznaczonej znaczkiem '*'
$a =& new A(10);
-$a->createRef();
+$a->stworzRef();
-$a->echoValue();
-$a->b->echoValue();
-$a->c->echoValue();
+$a->wyswietlWartosc();
+$a->b->wyswietlWartosc();
+$a->c->wyswietlWartosc();
$a->value = 11;
-$a->echoValue();
-$a->b->echoValue(); // *
-$a->c->echoValue();
+$a->wyswietlWartosc();
+$a->b->wyswietlWartosc(); // *
+$a->c->wyswietlWartosc();
/*
-output:
-class A: 10
-class B: 10
-class B: 10
-class A: 11
-class B: 11
-class B: 11
+wyj�cie:
+klasa A: 10
+klasa B: 10
+klasa B: 10
+klasa A: 11
+klasa B: 11
+klasa B: 11
*/
</programlisting>
</informalexample>