Answer the question
In order to leave comments, you need to log in
How to call overridden classes inside base class?
The situation is this: there are two base classes
<?php
namespace AppBase;
class App
{
protected $loader;
public function __construct()
{
$this->loader = new Loader();
}
}
<?php
namespace AppBase;
class Loader {}
<?php
namespace AppExample;
class App extends \AppBase\App {}
<?php
namespace AppExample;
class Loader extends \AppBase\Loader {}
Answer the question
In order to leave comments, you need to log in
I don’t understand why you need such a decision, but you can still try this
namespace AppBase;
class App
{
protected $loader;
public function __construct()
{
$reflectionClass = new \ReflectionClass($this);
$namespace = $reflectionClass->getNamespaceName(); //AppExample
echo $namespace;
/*Логика*/
}
}
namespace AppBase;
class Loader {}
namespace AppExample;
class App extends \AppBase\App {}
namespace AppExample;
class Loader extends \AppBase\Loader {}
$app = new \AppExample\App();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question