I was wondering if it is allowed to create an instance of a class inside another class.
Or, do I have to create it outside and then pass it in through the constructo
I just wanted to point out that it is possible to load a class definition dynamically inside another class definition.
Lukas is right that we cannot define a class inside another class, but we can include() or require() them dynamically, since every functions and classes defined in the included file will have a global scope. If you need to load a class or function dynamically, simply include the files in one of the class' functions. You can do this:
function some()
{
require('db.php');
$db = new Db();
...
}
http://php.net/manual/en/function.include.php