2016-02-27 147 views
0

我从我的控制器向我的视图发送变量responselaravel刀片模板中的FatalErrorException

所以在我看来,如果我这样做:

{{response}} 

我能看到的响应,所以它的存在。

然而这response是一个JSON格式字符串,所以我需要解析它,

我想这样做的刀片。

我想这

<!DOCTYPE html> 
<html> 
<head> 
<title>Master Response</title> 
</head> 
<body> 
{{ 
     $json_a = json_decode($response, true); 
     $hits = $json_a['hits']['hits']; 
}} 
</body> 
</html> 

,但我得到这个错误

Whoops, looks like something went wrong. 

1/1 
FatalErrorException in 95df32e49f76c09bb366fa2eba52e460d30085dd.php line 7: 
parse error 
in 95df32e49f76c09bb366fa2eba52e460d30085dd.php line 7 

回答

0

该刀片系统采用{{ $var }}呼应数据。如果您想在刀片服务器上使用PHP进行操作,您需要使用PHP标签,例如:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Master Response</title> 
</head> 
<body> 
<?php 
     $json_a = json_decode($response, true); 
     $hits = $json_a['hits']['hits']; 
?> 
</body> 
</html>