Thanks to both of you - I guess I should have searched a little bit more before posting, but I didn't know
what I was searching for! I got the name of it from the other thread - "method chaining."
This question actually arose because I'm working on two classes right now for a customer invoicing application - one for retrieving customer info(class Customer) and one for displaying it(class Display) - here's the simplified version(I don't have the code in front of me right now):
Code: Select all
class Customer {
var $name;
var $id;
function __construct($id) {
$this->id = $id;
$query = "SELECT name FROM customers WHERE id = $id";
$result = mysql_query($query);
$this->name = mysql_result($result,0,'name');
}
}
class Display extends Customer {
function printDetails() {
echo $this->name;
echo $this->id;
// Etc..obviously formatting and stuff.
}
}
$display = new Display();
$display->printDetails();
Display extends Customer, but Customer is constructed with ID as a parameter(so that we know which customer this is). When I instantiate Display, it's not taking a paramater, so when I call $display->printDetails() it (obviously) returns nothing.
I was hoping that "$this->something->somethingelse" would be my solution as I could instantiate Customer with an ID and then call on those variables through Display like so:
Code: Select all
$somecustomer = new customer(234);
$display = new Display();
$somecustomer->display->printDetails();
It looks like this is completely separate from what I hoped it would be, but ah well.
Thanks again!