I'd like to apologise for the ambiguous title, it's the best one I could think of to define my problem.
I've got a single class in PHP that I want to be invoked from other scripts and I have a few libraries that I want to be able to call functions from, but I want to be able to call those functions from the other libraries via the single class I already have.
class Core
{
// code
}
I want to essentially do the following, Function->Core->Library Function.
The reasoning behind this is that I don't want to have a bunch of classes that get included when the file is run, causing the user to have to remember a bunch of different class names.
This is what I would essentially hope to achieve (but i'm pretty sure this is incorrect syntax) $Core->Data->Get();
tadaam. That calls for Dependency Injection ;)
class Core
{
public $lib1;
public $lib2;
public function __construct(){
$this->lib1 = new Lib1Class();
$this->lib2 = new Lib2Class();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.