PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I've been using Classes for a while now and have never thought about asking this before for some reason but... is it possible to have a Class within another Class?
For example, let's say I have a Class named "Navigation" and within the Navigation Class I wanted another Class named "SubNav" which Navigation could use within itself?
class Daddy {
//a few functions etc
}
class Son extends Daddy {
//a few more functions and you can also call any function that is in the Daddy class.
}
If you dont want to inherit then you can pass classes to a class:
Np, i pass classes to classes all the time and a few things i have discovered from trial and error are:
1) If your passing more than one class, pass them as an array - it makes things so much neater and easier to access.
2) Pass the objects as references so another copy of the class isnt made, and you can also add/edit values in the original class ($test = new Test(&$dad);)