2016-02-27 139 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>