Extends problem (classes)
| From: | Trystano at aol dot com | Date: | Mon, 06 Oct 2003 13:44:19 +0000 |
| Subject: | Extends problem (classes) | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-21692@lists.php.net to get a copy of this message | ||
Hi all,
I am a newbie to OO programming in PHP, and am having a few teething problems
with the extends keyword (inheritance). I think that the following code
doesn't work because the 'Another' class doesn't extend the
'Something' class (I
have created it, but is not in this sample code). The setX function is definded
in the Something class which isnt shown. Also, when I type the word 'extends'
it doesn't get highlighted as being a key word. Can some please help.
class Another extends Something {
var $y;
function setY($v) {
$this->y=$v;
}
function getY() {
return $this->y;
}
} // Another class
$obj2 = new Something;
$obj2->setX(5);
$obj2->setY(6);