cvs: phpdoc-ar /language oop.xml

From: Date: Wed, 26 May 2004 23:14:22 +0000
Subject: cvs: phpdoc-ar /language oop.xml
Groups: php.doc.ar 
Request: Send a blank email to doc-ar+get-608@lists.php.net to get a copy of this message
hafid Wed May 26 19:14:22 2004 EDT Modified files: /phpdoc-ar/language oop.xml Log: Second Partial Translation. Always EN1.52 compatible.

http://cvs.php.net/diff.php/phpdoc-ar/language/oop.xml?r1=1.1&r2=1.2&ty=u Index: phpdoc-ar/language/oop.xml diff -u phpdoc-ar/language/oop.xml:1.1 phpdoc-ar/language/oop.xml:1.2 --- phpdoc-ar/language/oop.xml:1.1 Tue May 25 20:10:47 2004 +++ phpdoc-ar/language/oop.xml Wed May 26 19:14:21 2004 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="WIN-1256"?> -<!-- $Revision: 1.1 $ --> +<!-- $Revision: 1.2 $ --> <!-- EN-Revision: 1.52 Maintainer: hafid Status: working --> <chapter id="language.oop"> <title>ÇáÃÕäÇÝ "Classes" æÇáßÇÆäÇÊ "Objects"</title> @@ -307,30 +307,30 @@ </sect1> <sect1 id="language.oop.constructor"> - <title><literal>Constructors</literal></title> + <title>ÇáÈÇäíÇÊ: <literal>Constructors</literal></title> <caution> <simpara> - In PHP 3 and PHP 4 constructors behave differently. The PHP 4 - semantics are strongly preferred. + ÈÍÓÈ PHP 3 Ãæ PHP 4¡ ÊÊÕÑÝ ÇáÈóÇäöíóÇÊ ÈÕæÑÉ ãÊÛÇíÑÉ. ÊõÝÖøóá ÈÞæÉ + ÏáÇÆáíÉ PHP 4. </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). + ÇáÈÇäíÇÊ åí ÏæÇá Ýí ÕäÝ ÊÊã ãäÇÏÇÊåÇ ÂáíÇ + ÚäÏ ÇäÔÇÁ ãËíá "instance" ÌÏíÏ áÕöäÝ¡ ÈæÇÓØÉ + <literal>new</literal>. Ýí PHP 3¡ + ÊÕÈÍ ÏÇáÉ ãÇ ÈÇäíÉð ÚäÏãÇ ÊÊæÝÑ Úáì äÝÓ ÇáÅÓÇã ãËá + ÇáÕøöäÝ. Ýí PHP 4¡ ÊÕÈÍ ÏÇáÉ ãÇ ÈÇäíÉð ÚäÏãÇ + ÊÊæÝÑ Úáì äÝÓ ÇáÅÓã ãËá ÇáÕøöäÝ ÇáÐøí ÚõÑøöÝÊ Èå - + ÇáÝÑÞ ÏÞíÞ áßäå ÍÇÓã (ÇÓÊÚÑÖ ãÇ íÃÊí). </para> <informalexample> <programlisting role="php"> <![CDATA[ <?php -// Works in PHP 3 and PHP 4. +// íÚãá ãÚ PHP 3 æ PHP 4. class Auto_Cart extends Cart { function Auto_Cart() { $this->add_item("10", 1); @@ -342,31 +342,31 @@ </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. + íõÚÑøöÝõ åÐÇ ÕöäÝ Auto_Cart æåæ ÚÈÇÑÉ Úä ÓáøÉ "Cart" ÅÖÇÝÉ Åáì ÈÇäíÉ + ÊÞæã ÈÇÓÊåáÇá ÇáÓøáøÉ ÈÛÑÖ æÇÍÏ ãä ÇáÓøáÚÉ ÑÞã "10" + Ýí ßáø ãÑøÉ íÌÑí ÝíåÇ ÇäÔÇÁ ÝíåÇ Auto_Cart ÌÏíÏ ÈæÇÓØÉ "new". ÈÇãßÇä ÇáÈÇäíÇÊ + ÃÎÐ ÏáÇÆá "arguments"¡ æÇáÊíø íãßä Ãä Êßæä ÇÎÊíÇÑíøÉ¡ ããÇ + íÌÚáåÇ ÃßËÑ ÞÇÈáíÉ ááÇÓÊÎÏÇã ÈÔßá ãõÚúÊóÈóÑ. ááÇÓÊãÑÇÑ Ýí ÇáÞÏÑÉ Úáì ÇÓÊÎÏÇã ÇáÕøöäÝ + ãä Ïæä ÇáãóÚúáóãóÇÊ "parameters"¡ íÊæÌÈ ÌÚá ßÇÝÉ ÇáãóÚúáóãóÇÊ¡ ÈÇáäøÓÈÉ ááÈÇäíÇÊ¡ + ÇÎÊíÇÑíøÉ ÈÊÞÏíã Þíã ÇÝÊÑÇÖíøÉ. </para> <informalexample> <programlisting role="php"> <![CDATA[ <?php -// Works in PHP 3 and PHP 4. +// íÚãá ãÚ PHP 3 æ PHP 4. class Constructor_Cart extends Cart { function Constructor_Cart($item = "10", $num = 1) { $this->add_item ($item, $num); } } -// Shop the same old boring stuff. +// ÇÈÊíÇÚ äÝÓ ÇáÈÖÇÆÚ ÇáãõãøöáóÉ ÇáÞÏíãÉ. $default_cart = new Constructor_Cart; -// Shop for real... +// ÇÈÊíÇÚ ÍÞíÞíø... $different_cart = new Constructor_Cart("20", 17); ?> @@ -375,16 +375,16 @@ </informalexample> <para> - You also can use the <literal>@</literal> operator to - <emphasis>mute</emphasis> errors occurring in the constructor, e.g. + íãßäß ÃíÖÇ ÇÓÊÎÏÇã ãõÔÛøöá <literal>@</literal> ÈÛÑÖ + <emphasis>ßÊã "mute"</emphasis> ÇáÃÎØÇÁ ÇáØøóÇÑÆÉ Ýí ÇáÈÇäíÉ¡ Úáì ÓÈíá ÇáãËÇá: <literal>@new</literal>. </para> <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. + Ýí PHP 3¡ ÊÊæÝÑ Úáì ÇáÃÕäÇÝ ÇáãõÔÊøóÞóÉ æÇáÈÇäíÇÊ Úáì ÚÏÏ ãä + ÇáÊøóÞííÏÇÊ "limitations". íÌÈ ÞÑÇÁÉ ÇáÃãËáÉ ÇáÂÊíøóÉ ÈÇÍÊÑÇÓ + áÝåã åÐå ÇáÊøÞííÏÇÊ. </simpara> </caution> @@ -394,17 +394,17 @@ <?php class A { function A() { - echo "I am the constructor of A.<br />\n"; + echo "ÃäÇ ÈÇäíÉ A.<br />\n"; } } class B extends A { function C() { - echo "I am a regular function.<br />\n"; + echo "ÃäÇ ÏÇáÉ ÇÚÊíÇÏíøÉ.<br />\n"; } } -// no constructor is being called in PHP 3. +// áÇ ÈÇäíÉ íÌÑí ãäÇÏÇÊåÇ Ýí PHP 3. $b = new B; ?> ]]> @@ -412,17 +412,17 @@ </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. + Ýí PHP 3¡ æáÇ ÃíÉ ÈÇäíÉ ÊÊã ãäÇÏÇÊåÇ Ýí ÇáãËÇá ÇáÚáæíø. + ÇáÞÇÚÏÉ Ýí PHP 3 åí: 'ÈÇäíÉ ãÇ åí ÚÈÇÑÉ Úä ÏÇáÉ áåÇ äÝÓ + ÇáÅÓã ãËá ÇáÕøöäÝ.'. ÅÓã ÇáÕøöäÝ åæ B æáíÓ åäÇß + ÃíøÉ ÏÇáÉ ÊõÏÚóì B() Ýí ÇáÕøöäÝ B. áã íÍÏË ÔíÁ. </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.&lt;br /&gt;' in PHP 4. + Êãø ÊÞæíã åÐÇ ÇáÃãÑ Ýí PHP 4 ÈÅÏÎÇá ÞÇÚÏÉ ÃÎÑì: ÅÐÇ áã íÊæÝÑ ÕöäÝñ ãÇ + Úáì ÈÇäíÉ¡ ÝÅäøóå íÊã ãäÇÏÇÉ ÈÇäíÉ ÇáÕøöäÝ ÇáÞÇÚÏíø "base class"¡ + Åä æõÌöÏ. ÇáãËÇá ÇáÃÚáì íÄÏí Åáì ØÈÇÚÉ + 'ÃäÇ ÈÇäíÉ A.&lt;br /&gt;' Ýí PHP 4. </para> <informalexample> @@ -433,13 +433,13 @@ { function A() { - echo "I am the constructor of A.<br />\n"; + echo "ÃäÇ ÈÇäíÉ 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 "ÃäÇ ÏÇáÉ ÇÚÊíÇÏíøÉ ÊõÏúÚóì B Ýí ÇáÕøöäÝ A.<br />\n"; + echo "áÓÊ ÈÇäíÉ Ýí A.<br />\n"; } } @@ -447,11 +447,11 @@ { function C() { - echo "I am a regular function.<br />\n"; + echo "ÃäÇ ÏÇáÉ ÇÚÊíÇÏíøÉ.<br />\n"; } } -// This will call B() as a constructor. +// ÓíÄÏí åÐÇ Åáì ãäÇÏÇÉ B() Úáì ÃäøåÇ ÈÇäíÉ. $b = new B; ?> ]]> @@ -459,43 +459,43 @@ </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. + Ýí PHP 3¡ ÇáÏøÇáÉ B() Ýí ÇáÕøöäÝ A ÓÊõÕÈöÍ ÝÌÃÉ + ÈÇäíÉð Ýí ÇáÕøöäÝ B ÈÇáÑøÛã ãä ÚÏã ãÞÕæÏíÉ ÔíÁ ãä åÐÇ ÇáÞÈíá. + ÇáÞÇÚÏÉ Ýí PHP 3 åí: 'ÈÇäíÉñ ãÇ åí ÏÇáÉ áåÇ äÝÓ + ÇáÅÓã ãËá ÇáÕøöäÝ.'. áÇ ÊßÊÑË PHP 3 ÅÐÇ Êãø ÊÚÑíÝ ÇáÏøÇáÉ + Ýí ÇáÕøöäÝ B Ãæ ÅÐÇ ÊãøÊ æÑÇËÊåÇ. </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.&lt;br /&gt;'. + Êãø ÊÞæíã åÐÇ ÇáÃãÑ Ýí PHP 4 ÈÊÚÏíá ÇáÞÇÚÏÉ Åáì: 'ÈÇäíÉñ ãÇ + åí ÏÇáÉ áåÇ äÝÓ ÇáÅÓã ãËá ÇáÕøöäÝ ÇáÐøí ÌÑì ÊÚÑíÝåÇ + Èå.'. æåßÐÇ¡ ÝÅäøå ÈÜPHP 4¡ ÇáÕøöäÝ B áä íÊæÝÑ Úáì ÏÇáÉ ÈÇäíøÉ¡ + ÈãÈÇÏÑÉ ÐÇÊíøÉ¡ æÓÊÊã ãäÇÏÇÉ ÈÇäíÉ ÇáÕøöäÝ ÇáÞÇÚÏíø + áíõØúÈóÚ 'ÃäÇ ÈÇäíÉ A.&lt;br /&gt;'. </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. + áÇ PHP 3 æáÇ PHP 4 ÊõäÇÏí ÈÇäíÇÊ ÇáÕøöäÝ ÇáÞÇÚÏíø + ÂáíÇ ÇäØáÇÞÇð ãä ÈÇäíÉ ÕöäÝ ãõÔÊøóÞ. ÊÞÚ Úáì ÚÇÊöÞß + ãÓÄæáíÉ äÔÑ äÏÇÁ ÇáÈÇäíÇÊ + ÃÝÞíÇð ÍíË íáíÞ ÇáãÞÇã. </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. + áíÓÊ åäÇß åÇÏãÇÊ "destructors" Ýí PHP 3 Ãæ PHP 4. íãßäß ÇÓÊÎÏÇã + <function>register_shutdown_function</function> ÈÏáÇ ãä Ðáß + ÈÛÑÖ ãõÍÇßÇÉ ãõÚÙóã ÊÃËíÑÇÊ ÇáåÇÏãÇÊ. </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. + ÇáåÇÏãÇÊ åí ÏæÇá ÊÊã ãäÇÏÇÊåÇ ÂáíÇ + ÚäÏ ÊÍØíã ßÇÆä ãÇ¡ ÅãÇ ÈæÇÓØÉ <function>unset</function> + Ãæ ÈÈÓÇØÉ ÈÇáÎÑæÌ ãä ÇáãÏì "scope". áíÓÊ åäÇß åÇÏãÇÊ + Ýí PHP. </para> </sect1>
« previous php.doc.ar (#608) next »