0
"array_intersect_key() 인수 # 1은 배열이 아닌"나는 내 템플릿은 다음과 같이 오류 array_intersect_key(): Argument #1 is not an array
있어 :나뭇 가지를 던져 : 나는 슬림 프레임 워크와 나뭇 가지를 사용하고
{% extends 'main.tmpl' %}
{% block content %}
<h2>Teams</h2>
<ul>
{% for team in teams %}
<li>
<img src="/images/{{ team.name }}.png"/>
<a href="/team/{{ team.name }}">{{ team.name }}</a>
</li>
{% endfor %}
</ul>
{% endblock %}
내 PHP 코드를 다음과 같이 :
$app->get('/teams', function() use ($app) {
return $app->render("teams", array(
"teams" => array(array("name" => "Hello"))
));
});
내가 그룹에 템플릿 VAR 팀을 변경하고 같은 효과를하려고했습니다. 이 오류를 수정하는 방법? 템플릿이이 예외를 throw하는 이유는 무엇입니까?
와 View 클래스 :$twig = new Twig_Environment(new Twig_Loader_Filesystem('views'));
class View extends \Slim\View {
protected function render($template) {
global $twig;
throw new Exception("Hello");
if (substr($template, -5) !== '.tmpl') {
$template .= '.tmpl';
}
return $twig->render($template, $this->data);
}
}
UPDATE : 스택 트레이스
Details
Type: Twig_Error_Runtime
Message: An exception has been thrown during the rendering of a template ("array_intersect_key(): Argument #1 is not an array") in "teams.tmpl" at line 9.
File: /home/kuba/projects/euro2012/libs/Twig/lib/Twig/Template.php
Line: 146
Trace
#0 /home/kuba/projects/euro2012/libs/Twig/lib/Twig/Environment.php(331) : eval()'d code(63): Twig_Template->displayBlock('content', Object(Slim\Helper\Set), Array)
#1 /home/kuba/projects/euro2012/libs/Twig/lib/Twig/Template.php(276): __TwigTemplate_cafc9f26650a81c1b7c5fc9d1e485dc009273ca6a578c04f8bdf5826f601fb58->doDisplay(Object(Slim\Helper\Set), Array)
#2 /home/kuba/projects/euro2012/libs/Twig/lib/Twig/Template.php(250): Twig_Template->displayWithErrorHandling(Object(Slim\Helper\Set), Array)
#3 /home/kuba/projects/euro2012/libs/Twig/lib/Twig/Environment.php(331) : eval()'d code(24): Twig_Template->display(Object(Slim\Helper\Set), Array)
#4 /home/kuba/projects/euro2012/libs/Twig/lib/Twig/Template.php(276): __TwigTemplate_164a4230b6490af9d793411b328170b5a5588e62f33a13c07c0f769bb7a3f06b->doDisplay(Object(Slim\Helper\Set), Array)
#5 /home/kuba/projects/euro2012/libs/Twig/lib/Twig/Template.php(250): Twig_Template->displayWithErrorHandling(Object(Slim\Helper\Set), Array)
#6 /home/kuba/projects/euro2012/libs/Twig/lib/Twig/Template.php(261): Twig_Template->display(Object(Slim\Helper\Set))
#7 /home/kuba/projects/euro2012/libs/Twig/lib/Twig/Environment.php(292): Twig_Template->render(Object(Slim\Helper\Set))
#8 /home/kuba/projects/euro2012/bootstrap.php(23): Twig_Environment->render('teams.tmpl', Object(Slim\Helper\Set))
#9 /home/kuba/projects/euro2012/libs/Slim/Slim/View.php(255): View->render('teams', NULL)
#10 /home/kuba/projects/euro2012/libs/Slim/Slim/View.php(243): Slim\View->fetch('teams', NULL)
#11 /home/kuba/projects/euro2012/libs/Slim/Slim/Slim.php(751): Slim\View->display('teams')
#12 /home/kuba/projects/euro2012/index.php(29): Slim\Slim->render('teams', Array)
#13 [internal function]: {closure}()
#14 /home/kuba/projects/euro2012/libs/Slim/Slim/Route.php(441): call_user_func_array(Object(Closure), Array)
#15 /home/kuba/projects/euro2012/libs/Slim/Slim/Slim.php(1314): Slim\Route->dispatch()
#16 /home/kuba/projects/euro2012/libs/Slim/Slim/Middleware/Flash.php(85): Slim\Slim->call()
#17 /home/kuba/projects/euro2012/libs/Slim/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()
#18 /home/kuba/projects/euro2012/libs/Slim/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#19 /home/kuba/projects/euro2012/libs/Slim/Slim/Slim.php(1261): Slim\Middleware\PrettyExceptions->call()
#20 /home/kuba/projects/euro2012/index.php(39): Slim\Slim->run()
#21 {main}
이 코드에서'array_intersect_key()'가 어디에서 나타나는지 알 수 없습니다. 스택 추적을 게시 할 수 있습니까? –
@cryptic ツ 스택 추적을 추가했습니다. – jcubic