Extends problem (classes)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux