$this
을 경로의 기능 안에서 사용하려고 할 때,이 작업을 수행 할 때 다음과 같은 메시지가 표시됩니다 오류 : 나는 this에 기반을 구현하기 위해 노력했다
function api($request, $response) {
$response->write('REST API v1');
$this->logger->addInfo("Something interesting happened");
return $response;
}
$app = new \Slim\App();
/** my routes here **/
$app->get('/', 'api');
$app->run();
:
Using $this when not in object context
여기에 코드입니다.
왜 함수 내에 $this
을 사용하지 못하고 함수 내에 $this
을 사용할 수 있습니까?
-> ...'? – jmattheis
내 모든 경로 기능에서 – JackTheKnife
질문에 예제를 추가하십시오 – jmattheis