barak Sat Jan 26 19:08:00 2002 EDT
Modified files:
/phpdoc/he/language oop.xml
Log:
most of file, was translated, but with a lot of mistakes... still work on it
Index: phpdoc/he/language/oop.xml
diff -u phpdoc/he/language/oop.xml:1.1 phpdoc/he/language/oop.xml:1.2
--- phpdoc/he/language/oop.xml:1.1 Fri Jan 25 19:54:53 2002
+++ phpdoc/he/language/oop.xml Sat Jan 26 19:08:00 2002
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<chapter id="language.oop">
<title>Classes and Objects</title>
@@ -251,7 +251,7 @@
</sect1>
<sect1 id="language.oop.constructor">
- <title><literal>Constructors</literal></title>
+ <title><literal>�����</literal></title>
<caution>
<simpara>
@@ -446,10 +446,10 @@
</caution>
<para>
- ������ �� ������ ������� � 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.
+ ������ �� ������ ���� ����� ������� ��������� ������
+ ����� �� ������ ������ ��������� ��� ������ �������
+ ������ �� ����� ��� ���� (����� �� ���� ��� �������).
+ �������� :: ���� ������ ����� ���.
</para>
<informalexample>
@@ -472,15 +472,15 @@
}
}
-// there is no object of class A.
-// this will print
+// ��� ������� ������ A.
+// �� ����� ����� ����� ����� ��:
// I am the original function A::example().<br>
A::example();
-// create an object of class B.
+// ����� ������� (���� "����") ������ 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();
@@ -489,60 +489,60 @@
</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.
+ ������ ������ ����� �������� example() �����
+ ������ A, ��� ��� ������� ������ A, ������
+ �� ���� ����� $a->example() �� ���� ����. ����� ���
+ ����� �������� example() � '������� �����', �����, ���
+ ����� �������� �� ������ ����, ��� ������ ����� ��
+ ���� �����.
</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.
+ �� �������� ������, ��� ��� ������ ������.
+ �����, ��� ������� ����� ���� �� ���� ��������
+ ���, �������� �� ������ �� ������ ������ ������� �� �������� (���
+ �� ������ ������ ������� ��������� ��������), ��� �� ������ ������ � -
+ $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).
+ ������ ����, ������ B ������ ���� �� �������� example().
+ ������ ������� ���� ������ A "������"
+ ��� ������� �����, �� ��� ������� �������
+ ������ �� example() ����� ������ A ��� ����� ��������
+ :: . ������ �� A::example() ���� ��� (�����, ����
+ �����: parent::example(), ��� ������ ����
+ ���).
</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.
+ ����� ��, ���� ������� ������ �����
+ �� ����� �������. ���, ��������� ������� ���� ������� ��������,
+ ���� ������ � $this ������� �����.
</para>
</sect1>
<sect1 id="keyword.parent">
- <title><literal>parent</literal></title>
+ <title><literal>����</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.
+ ������ ������ ��� ������ � ������
+ ��������� ��� ������ ������ ����. ��� ��
+ ����� ������ �� ������ ������� ������ ��� ����� ��
+ ���� ������ ���� �� ���� ����� ������ �����.
</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.
+ ����� ������ ��� ������� (������) �� ������ ����� �� ����,
+ ���� ���� ����� � �� ������
+ <literal>parent</literal>, ������ ����� �� ��� �� �����
+ ����� ��� ������ ��� ����� ������ <literal>extends</literal>
+ ������ ���. ����� ����� ���, ������ ������ ���
+ �� ����� ����� ����� ����� ���. ���,
+ ������� ����� ������ �� ������� ,
+ ����� ����� �� ��� ������
+ <literal>extends</literal> ����� ������ �� ������.
</para>
<informalexample>
@@ -575,45 +575,46 @@
</sect1>
<sect1 id="language.oop.serialization">
- <title>Serializing objects - objects in sessions</title>
+ <title>"��������� �������" - ��������� � session</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).
+ � PHP 3, �������� ����� �� ����� ������ ����
+ ����� ������ �� "����� �������" (serializatio) � "�� ����� �������"
+ (unserialization).
+ ������ ��� ����� ���� �������, ��� ��� �����
+ ���� ������ (�������� �� ������), ��� �� ��� �� ������ (�� ����� ����
+ ��� ��� ���� �� ����� �����).
</simpara>
</note>
<caution>
<simpara>
- The following information is valid for PHP 4 only.
+ ����� ����� ��� � - 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> ����� ������ ������
+ "��� ����" ��������� �� ��� ��� ����� ����� ����� ���� �
+ PHP. <function>unserialize</function> ������� ������� ��
+ ������ ���� �� ������ ������� �� �����. ����� � serialize
+ ������ �������� ����� ����� �� �� ������� ���������.
+ ��������� ��������� �� �����, �� ��� �� ������
+ ��� �� �����.
</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.
+ �� ��� ������ � <function>unserialize</function> ��
+ �������, ������ �� ���� ������� ����� ����� ������. ������,
+ �� �� �� �������� $a �� ������ A ���� page1.php �����
+ serialize ����, ����� ������ ������ ������ A
+ ���� ���� �� �� ������ �� ������� ������� $a.
+ ���� ���� ������ � unserialize �� page2.php,
+ ����� ���� �� ������� $a �� ������ A, ������ �� ������ A �����
+ ����� ������ � - page2.php. �� ���� ������ ������ �� ���
+ ������ �� ����� ������ A ���� ���� �����
+ ������ ���� �� �� � page1.php ��� � page2.php.
</para>
<informalexample>
@@ -635,91 +636,90 @@
$a = new A;
$s = serialize($a);
- // store $s somewhere where page2.php can find it.
+ // ������ $s ����� ����� �� page2.php ���� ����� ����.
$fp = fopen("store", "w");
fputs($fp, $s);
fclose($fp);
page2.php:
- // this is needed for the unserialize to work properly.
+ // �� ���� �� ��� ���� unserialize ����� ������.
include("classa.inc");
$s = implode("", @file("store"));
$a = unserialize($s);
- // now use the function show_one() of the $a object.
+ // ����� �������� show_one() ������ �� �������� $a.
$a->show_one();
]]>
</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 ������ � <function>session_register</function>
+ �� ��� ����� �����, ��������� ��� ����� ������� serialized
+ ���� �� ���� PHP, ��� unserialized ��������
+ ���� ��� ����� �����. ������ ������� ��� ���������
+ ���� ������ ��� ������ ���� ��� ������ ����� ��� ���� �
session.
</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.
+ ���� ����� ������ �� ����� ������
+ �� �� ���������� �������� �� �� ����
+ ����, �� �� ��� �� ���� ����� ����� ������ ���
+ ���� ����. �� ��� �� ����� �������� ���
+ unserialized ��� ����� ������ �������, ���
+ ���� �� ����� ������ ������ �������� �� ������
+ <literal>stdClass</literal> ��� ������� ����� ��������
+ ����, �����, ��� ���� ��� ������ ���.
</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 ���� ���� � session ��� ���
+ ����� � <literal>session_register("a")</literal>, �� ����
+ ������ �� ����� <literal>classa.inc</literal> ��� �����,
+ �� �� ����� page1.php � page2.php.
</para>
</sect1>
<sect1 id="language.oop.magic-functions">
- <title>The magic functions <literal>__sleep</literal> and
<literal>__wakeup</literal></title>
+ <title>"�������� ����": <literal>__sleep</literal> �
+<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> ���� �� ������ �� ������� ��
+ "���� ����" <literal>__sleep</literal>. �� �� ����, ������� ��
+ ������ ���� ���� �� serialization. ��� ����� ����� �� ��������
+ ���� ����� ������ ���� �� ���� �� �������
+ �� ���� ������� ����� ����� serialized.
</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.
+ ���� ��� ����� � <literal>__sleep</literal> ��� �����
+ ����� ����� ���� ������ ����� ����� ��������, ���� ����� ����
+ ����� ����� �� ���� ������ ����� �����. ��, �������� ���
+ ������� �� �� ������� ���� ���� ��� ���� ������ ����.
</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 resources that object may have.
+ ������, <function>unserialize</function> ���� ������
+ �� ������� �� ���� ����
+ <literal>__wakeup</literal>. �� ����� �����, ������� �� �����
+ ����� ���� ���� ����� ����� ����� ��������.
</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.
+ ������� � <literal>__wakeup</literal> ���� ����� ����
+ ����� ���� ������ ����� ����� ���� ������
+ ����� serialization ����� reinitialization ��
+ ����� ����.
</para>
</sect1>
<sect1 id="language.oop.newref">
- <title>References inside the constructor</title>
+ <title>����� ����� ������</title>
<para>
- Creating references within the constructor can lead to confusing
- results. This tutorial-like section helps you to avoid problems.
+ ����� ����� ������ ���� ������ ������� �������.
+ ��� �� ������ ���� �� ����� ������� ������.
<informalexample>
<programlisting role="php">
@@ -753,11 +753,11 @@
</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...
+ ����� �� �� ���� ���
+ <varname>$bar1</varname> ����� ��� ����� ����� �� ��������
+ <literal>=</literal> ���
+ <varname>$bar2</varname> ����� ��� ����� �������� ������
+ <literal>=&</literal> ...
<informalexample>
<programlisting role="php">
@@ -784,24 +784,24 @@
</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.
+ ���� ���� �� ����, ��� ����� �� ���� �������
+ ���� ���: <varname>$bar1</varname> �
+ <varname>$globalref[0]</varname> �� �� �������, ��
+ �� ���� �����. ��� ���� � "new" �� �����
+ ���� ������ ����, ����� ��� ��� ����� ����.
<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).
+ ��� ����� �� ������� (���� � PHP 4 ����� ������� �������
+ �����) �������� ������ ����� �����. ��� ���
+ �� ����� ������ ���� ���� ����� �� ������
+ ����� �� "�������", ���� ������ "�������" ����� ��� ��
+ ������� ������ ��������� ���� ����� ��� ����� (�� ��� �� ��� ���
+ ��� �� ���� ���� �� ������� and ����� ��� �����
+ ����(��) ���� ���, ���� ��� �� ���� ��� ������
+ �������� ����� �� ���� �� �����).
</simpara>
</note>
- To prove what is written above let us watch the code below.
+ ������ �� �� ����� ����� �� ����� �� ���� ���:
<informalexample>
<programlisting role="php">
@@ -834,7 +834,7 @@
</informalexample>
</para>
<para>
- Another final example, try to understand it.
+ ����� ��� �����, ����� ����� ����� ����.
<informalexample>
<programlisting role="php">