cvs: phpdoc-hu /language/oop5 decon.xml

[email protected] ("Lajos Cseppent?")
Newsgroups php.doc.hu
Message-ID <cvschappy1161447947@cvsserver>
chappy		Sat Oct 21 16:25:47 2006 UTC

  Added files:                 
    /phpdoc-hu/language/oop5	decon.xml 
  Log:
  sync
  

http://cvs.php.net/viewvc.cgi/phpdoc-hu/language/oop5/decon.xml?view=markup&rev=1.1
Index: phpdoc-hu/language/oop5/decon.xml
+++ phpdoc-hu/language/oop5/decon.xml
<?xml version="1.0" encoding="iso-8859-2"?>
<!-- EN-Revision: 1.11 Maintainer: chappy Status: ready --> 
 <sect1 id="language.oop5.decon">
  <title>Konstruktorok és destruktorok</title>

  <sect2 id="language.oop5.decon.constructor">
   <title>Konstruktor</title>
   <methodsynopsis>
    <type>void</type><methodname>__construct</methodname>
    <methodparam choice="opt"><type>mixed</type><parameter>args</parameter></methodparam>
    <methodparam choice="opt"><parameter>...</parameter></methodparam>
   </methodsynopsis>
   <para>
    A PHP 5 lehetõvé teszi a fejlesztõk számára, hogy konstruktor metódust 
	deklaráljanak osztályoknak. Azok az osztályok, melyeknek van konstruktor metódusuk, 
	meghívják ezt a metódust minden egyes újonnan létrehozott objektumon, ezért 
	ez alkalmas bármilyen kezdeti beállításhoz ami az objektum számára szükséges 
	a használata elõtt. 
   </para>
   <note>
    <simpara>
	 A szülõ konstruktor nem hívódik meg, ha az utód osztály definiál egy konstruktort. 
	 A szülõ konstruktor futtatásához meg kell hívni a <function>parent::__construct</function> 
	 metódust az utód konstruktorban. 
    </simpara>
   </note>
   <example>
    <title>Új egységes konstruktorok használata</title>
    <programlisting role="php">
<![CDATA[
<?php
class BaseClass {
   function __construct() {
       print "BaseClass konstruktor\n";
   }
}

class SubClass extends BaseClass {
   function __construct() {
       parent::__construct();
       print "SubClass konstruktor\n";
   }
}

$obj = new BaseClass();
$obj = new SubClass();
?> 
]]>
    </programlisting>
   </example>
   <para>
    A visszafelé kompatibilitás érdekében ha a PHP 5 nem talál 
	<function>__construct</function> függvényt az addot osztályban, 
	megkeresi a régi stílusú konstruktor függvényt, aminek a neve 
	megegyezik az osztályéval. Hathatósan ez azt jelenti, hogy csak akkor 
	van kompatibilitási probléma, ha az osztálynak van egy metódusa 
	<function>__construct</function> néven és másmilyen a szemantikája 
	(más lenne az eredeti célja, nem az, hogy konstruktor legyen).
   </para>
  </sect2>

  <sect2 id="language.oop5.decon.destructor">
   <title>Destruktor</title>
   <methodsynopsis>
    <type>void</type><methodname>__destruct</methodname>
    <void />
   </methodsynopsis>
   <para>
    A PHP 5 által bevezetett destruktor hasonló a többi objektum-orientált nyelvekéhez, 
	mint a C++. A destruktor metódus akkor hívódik meg, amint az összes referencia az 
	egyéni objektumhoz vagy amikor az objektum nyíltan megsemmisül.
   </para>
   <example>
    <title>Destruktor példa</title>
    <programlisting role="php">
<![CDATA[
<?php
class MyDestructableClass {
   function __construct() {
       print "Konstruktor\n";
       $this->name = "MyDestructableClass";
   }

   function __destruct() {
       print $this->name . " megsemmisítése\n";
   }
}

$obj = new MyDestructableClass();
?> 
]]>
    </programlisting>
   </example>
   <para>
    A konstruktorokhoz hasonlóan, a szülõ destruktort nem hívja meg a motor közvetlenül. 
	A szülõ destruktor futtatásához nyíltan meg kell hívnod a 
	<function>parent::__destruct</function> metódust a destruktorban.
   </para>
   <note>
    <para>
	 A destruktor a program leállítása során hívódik meg, tehát a fejlécek 
	 már mindig el vannak küldve. 
    </para>
   </note>
   <note>
    <para>
	 Kivétel dobása a desturktorból fatális hibát eredményez. 
    </para>
   </note>
  </sect2>

 </sect1>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.