'extends' problem (Classes)

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

 



Sorry if this is a double post for some of you, but I sent this email earlier 
today and had a strange email in a foreign language which seems like an email 
blocker. If any of you have received this email today, please delete it.

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). Is there a problem with 
inheritance in PHP 4.2.3. 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.

(am using Apache on XP)

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

// End Code

Tryst

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