Class Inheritance issue
Posted: Wed Oct 24, 2007 3:51 pm
Hi,
I recently decided to upgrade to PHP 5, and wiith all the new ))) features I thought it was time to rewrite some of my existing code. However I've ran into a problem when inherting (exttending) a class from a base class.
I define my base class:
I then define my child class:
I have simplified my classes for clarity, the problem I am having is that the child class define additional public variables, such as $TextBox1. The child class also inherits the function createControls(). I require the function createControl() in the base class to have access to $TextBox.. I would therefore try something like this in my code.
from the code above, I would expect $from_NewStaff->TextBox1 to be set to "Hello World"
But naturally, I cannot get this to happen! Is it possible?
Thanks
Musaffar Patel
I recently decided to upgrade to PHP 5, and wiith all the new ))) features I thought it was time to rewrite some of my existing code. However I've ran into a problem when inherting (exttending) a class from a base class.
I define my base class:
Code: Select all
class TForm
{
public $Name;
function __construct($name)
{
$this->Name = $name;
}
function createControls()
{
$TextBox1 = "Hello World";
}
}Code: Select all
class TForm_NewStaff
{
public $TextBox1;
}I have simplified my classes for clarity, the problem I am having is that the child class define additional public variables, such as $TextBox1. The child class also inherits the function createControls(). I require the function createControl() in the base class to have access to $TextBox.. I would therefore try something like this in my code.
Code: Select all
$frm_NewStaff = TForm_NewStaff
$frm_NewStaff->createControls();But naturally, I cannot get this to happen! Is it possible?
Thanks
Musaffar Patel