Answer the question
In order to leave comments, you need to log in
How does class visibility work in PHP, in my example?
I can not fully understand how the classes behave. For example, on the slim framework in index.php I write:
// мой класс
class Home {
public function index(){
return 'Home controller';
}
}
//мой роутер
$app->get('/', function (Request $request, Response $response) {
$response = $this->view->render($response, 'index.phtml');
return $response;
});
$test = new Home; var_dump($tes);
and it works. This confuses me, I didn't expect the template to have access to the class. I would appreciate an explanation.
Answer the question
In order to leave comments, you need to log in
in the same template (index.phtml) I can write for example $test = new Home; var_dump($tes t ); and it works.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question