You are here: Building on classes -- inheritance help needed « PHP Programming Language « IT news, forums, messages
Building on classes -- inheritance help needed

Posted by mountain.dog on 03/21/07 15:13

Hi There,
I'm trying to understand inheriting properties object and I'm not
fully understanding the ways to accomplish this.

For example, I have a PHP array that is generate in "class a". I
would like to use this array with its values in "class b". When I
create a new instance of "class b" I get the array but none of the
values are present. Make sense? An explanation on how to accomplish
this would be great. A simplified example is below. Any help /
guidance would be greatly welcome. -- CH

class a {
public $one;

public function someMethod() {
$one = array("1");
}
}

class b extends class a {
public $one;
public $two

function someOtherMethod() {
print_r($this->one);
}
}

$display = new a;
$displayb = new b($a);
$displayb->someOtherMethod();

//outputs
Array ( [0] => )

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация