AxAn
Nov 20th, 2008, 04:38 AM
Is it possible to declare a class in another class?, like:
class FirstClass {
class SecondClass {
public $fName;
public $lName;
public $age;
}
...some code
}
I seem to remember doing this in PHP4 but I do not get it to work in PHP5.
The reason I want to do it it to send around parameters in a nice way in the class (FirstClass). I could use an array but its nicer to use a class when coding in an IDE since it auto completes the variable names in the class when using an object.
I have been seaching for an answer but not found much, maybe since it's hard to search for "class in class".
class FirstClass {
class SecondClass {
public $fName;
public $lName;
public $age;
}
...some code
}
I seem to remember doing this in PHP4 but I do not get it to work in PHP5.
The reason I want to do it it to send around parameters in a nice way in the class (FirstClass). I could use an array but its nicer to use a class when coding in an IDE since it auto completes the variable names in the class when using an object.
I have been seaching for an answer but not found much, maybe since it's hard to search for "class in class".