trouble with php object inheritance

skiskifollert

New Member
I am building a page through a series of include files. Many (not all) of the include files are classes of various things that I need stored as objects. For instance, one of my pages is:\[code\] class site { var $siteid; var $sitename; function __construct($id, $name) { $this->siteid = $id; $this->sitename = $name; } function get_siteid(){ return $this->sitename; }\[/code\]and then on another page I have:\[code\]$site = new site("4","My Site");\[/code\]So, on a subsequent include page I create another class called "page". While creating this class I need to reference the siteid value instantiated previously for $site, but I can't seem to get at it.I've tried $site->get_siteid() but I get a message that says "undefined variable."Strangely, on a regular HTML page later on, I am able to get the site id simply with $site->siteid, but from what I have read this is not a good practice, and this also doesn't work within the page class anyway.I'm still pretty new to OO coding and so I am sure I am missing something pretty basic here, but have tried a lot of things and cannot seem to make it work.Thanks in advance. :)
 
Back
Top