note 31265 deleted from keyword.parent by didou
| From: | didou@php.net | Date: | Thu, 03 Jul 2003 09:43:33 +0000 |
| Subject: | note 31265 deleted from keyword.parent by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-51412@lists.php.net to get a copy of this message | ||
Note Submitter: emmix -> emmix@wa.home.pl
----
Problem comprehension the class extends and inheritance variables:
class A {
var $x;
function val() { return $this->x; }
}
class B extends A {
function B() { echo(parent::val()); }
}
..............
$a1=new A; $a1->x=1; // $x in $a1 have value 1
$a2=new A; $a2->x=2; // $x in $a2 have value 2
$b=new B; // result: !isset or 0.
..............
new B use procedure "val" from class A. Both object $a1 and $a2 have some physical
procedures. But variables have different physical! Thus function "val" consumption
variable $x from $a1, if from $a2 ?. HOW COME function val() MUST HAVE knowledgle where from use
variable $x ?.