note 33702 added to keyword.extends
| From: | mazsolt at yahoo dot com | Date: | Fri, 04 Jul 2003 13:49:37 +0000 |
| Subject: | note 33702 added to keyword.extends | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51512@lists.php.net to get a copy of this message | ||
Just a simple example about inheritance:
class a1{
var $a=10;
function a1($a){
$this->a=$a;
}
}
class a2 extends a1{
var $x=11;
function a2($x,$y){
$this->x=$x;
parent::a1($y); // or a1::a1($y) or $this->a1($y)
}
}
class a3 extends a2{
var $q=999;
}
$x=new a3(99,9);
echo $x->a,"<br>",$x->x,"<br> ",$x->q;
The output will be:
9
99
999
----
Manual Page -- http://www.php.net/manual/en/keyword.extends.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33702
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33702&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33702&report=yes