By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,046 Members | 1,200 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,046 IT Pros & Developers. It's quick & easy.

Object delegation possible in PHP4?

P: n/a


Perhaps I'm using the wrong terminology, but is object delegation (as
opposed to inheritance) possible?, i.e. the line

$this->registration->displayStatus;
in the example below.

E.g. if one were to call

# Instantiate a new helpdesk
$helpdesk = new helpdesk ('theUsername', 'thePassword');

# Check
$helpdesk->checkUserStatus ();

why does this not give the result:

Registered

Or do I just need some sort of other syntax?

# Define a helpdesk application class
class helpdesk
{
# Constructor
function helpdesk ($username, $password)
{
# Instantiate a registration
$this->registration = new registration ($username, $password)

# Do more stuff in this constructor
}

# Some other function
function checkUserStatus ()
{
$this->registration->displayStatus;
}
}
# Define a registration class which applications can use
class registration
{
# Constructor
function registration ($username, $password)
{
// Validation of username & password at doCheck
$this->registered = (doCheck);
}

# Another function
function displayStatus ()
{
echo ($this->registered ? 'Registered' : 'Not registered');
}
}

Martin
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <Pi*******************************@yellow.csi.cam. ac.uk>,
Martin Lucas-Smith <mv***@cam.ac.uk> wrote:
$this->registration->displayStatus;


Without following everything line by line, so I could be wrong here, but
could it simply be that you need to do:

$this->registration->displayStatus();

i.e. () obligatory with a method call?

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.