I have a Class like this
class View
{
// Parameter die an das template übergeben werden
protected static $params = Array();
// Parameter die vom Routing übergeben werden
public static $routeParams;
// haupttemplate
protected static $viewMainContent;
// view template
protected static $viewFileContent;
// view pfad
protected static $pathTpl;
// controller pfad
protected static $pathCtrl;
protected $login;
// ausgabe des templates
public static function get($view, $params = "", $master = "main"){
$this->$login = new Login();
self::$pathTpl = Config::get('SRVROOT') . '/views/';
self::$pathCtrl = Config::get('SRVROOT') . '/controller/';
self::$routeParams = $params;
// prüfen ob main template oder custom
....................
....
Another class is an non-static class. Now i want to load the non-static class in my static class. I my View class i want use the functions from my Login class.
Thats an templating class and i have a function in the View class. In this function i load an defined controller (xxx.php) and in this file i want to use all classes thsts exist .
protected static function get_controller($file){
$ctrlFile = self::$pathCtrl . $file.'.php';
!file_exists($ctrlFile) || require_once($ctrlFile);
}
In the file thats included from the function i have this code.
if($login->user()){ echo "Hallo ich bin eingeloggt"; }
The error that coms in browser
Fatal error: Uncaught Error: Using $this when not in object context in /home/vagrant/Cloud/60_Projekte/SeitenVorlage/lib/class.templating.php on line 25
How can I do that?