Answer the question
In order to leave comments, you need to log in
Why can't a static method be called on a context variable containing the class name?
Such a thing:
<?php
class AutoLoader
{
protected $classname;
const classFolder = 'Class/';
private function __construct($classname) {
$this->classname = $classname;
}
protected function Test() {
return method_exists($this->classname, '__test') ? $this->classname::__test() : true; // unexpected "::" operator at this line.
}
protected function GetFilePath() {
return self::classFolder.str_replace('\\', DIRECTORY_SEPARATOR, $this->classname);
}
public static function Load($classname) {
$this = new self($classname);
$filepath = self::GetFilePath();
return file_exists($filepath) && include_once($filepath) && self::Test();
}
}
Answer the question
In order to leave comments, you need to log in
stop sawing bikes https://github.com/php-fig/fig-standards/blob/mast...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question