svn: /phpdoc/bg/trunk/reference/classobj/ examples.xml

From: Date: Sun, 19 Jun 2016 22:21:47 +0000
Subject: svn: /phpdoc/bg/trunk/reference/classobj/ examples.xml
Groups: php.doc.bg 
Request: Send a blank email to doc-bg+get-3034@lists.php.net to get a copy of this message
stanprog Sun, 19 Jun 2016 22:21:47 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=339411 Log: sync with EN Changed paths: U phpdoc/bg/trunk/reference/classobj/examples.xml Modified: phpdoc/bg/trunk/reference/classobj/examples.xml =================================================================== --- phpdoc/bg/trunk/reference/classobj/examples.xml 2016-06-19 22:17:12 UTC (rev 339410) +++ phpdoc/bg/trunk/reference/classobj/examples.xml 2016-06-19 22:21:47 UTC (rev 339411) @@ -1,14 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> -<!-- EN-Revision: 337717 Maintainer: stanprog Status: ready --> +<!-- EN-Revision: 339407 Maintainer: stanprog Status: ready --> <!-- Reviewed: yes Maintainer: stanprog --> <appendix xml:id="classobj.examples"> &reftitle.examples; <para> - В този пример, първо дефинираме базов клас и наследник на класа. - Базовият клас описва общо растение, дали е ядливо или не и какъв е цветът му. - Подкласът <varname>Spinach</varname> (спанак) добавя метод за сготвянето му - и друг за проверка дали е сготвен. + В този пример, първо дефинираме базов клас и наследник + на класа. Базовият клас описва общо растение, + дали е ядливо или не и какъв е цветът му. Подкласът + <varname>Spinach</varname> (спанак) добавя метод за сготвянето му и друг за + проверка дали е сготвен. </para> <para> <example> @@ -20,46 +21,47 @@ // базов клас с членове-променливи и методи class Vegetable { - var $edible; - var $color; + var $edible; + var $color; - function Vegetable($edible, $color="green") - { - $this->edible = $edible; - $this->color = $color; - } + function Vegetable($edible, $color="green") + { + $this->edible = $edible; + $this->color = $color; + } - function is_edible() - { - return $this->edible; - } + function is_edible() + { + return $this->edible; + } - function what_color() - { - return $this->color; - } + function what_color() + { + return $this->color; + } } // край на клас Vegetable // наследява базовия клас class Spinach extends Vegetable { - var $cooked = false; + var $cooked = false; - function Spinach() - { - $this->Vegetable(true, "green"); - } + function Spinach() + { + $this->Vegetable(true, "green"); + } - function cook_it() - { - $this->cooked = true; - } + function cook_it() + { + $this->cooked = true; + } - function is_cooked() - { - return $this->cooked; - } + function is_cooked() + { + return $this->cooked; + } + } // край на клас Spinach @@ -86,14 +88,14 @@ // помощни функции -function print_vars($obj) +function print_vars($obj) { foreach (get_object_vars($obj) as $prop => $val) { echo "\t$prop = $val\n"; } } -function print_methods($obj) +function print_methods($obj) { $arr = get_class_methods(get_class($obj)); foreach ($arr as $method) { @@ -101,7 +103,7 @@ } } -function class_parentage($obj, $class) +function class_parentage($obj, $class) { if (is_subclass_of($GLOBALS[$obj], $class)) { echo "Обект $obj е от клас " . get_class($GLOBALS[$obj]);

« previous php.doc.bg (#3034) next »