SilverStripe - 模板变量抛出错误
SilverStripe - Template Variable Throwing Error
我启动了一个非常基本的功能。我开始非常简单 in code/Page.php
:
public function createGreeting() {
return 'hi';
}
在我的 Page.ss
模板中,我有变量:<% $createGreeting %>
然而,这正在终止页面。我检查了错误日志,它显示:
PHP message: PHP Warning: Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set. in /usr/share/nginx/html/lungmap/framework/control/Director.php on line 488" while reading upstream, client: 31.210.102.114, server: 52.90.93.59, request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/var/run/php/php5.6-fpm.sock:" 2017/06/12 12:34:50 [error] 1730#0: *6682 FastCGI sent in stderr: "PHP message: PHP Warning: Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set. in /usr/share/nginx/html/lungmap/framework/control/Director.php on line 488
知道是什么原因造成的吗?如果我从 Page.ss
中删除该行,页面加载完全正常。
您不应该将变量包装在 <% %>
块中,而是直接调用它。
我启动了一个非常基本的功能。我开始非常简单 in code/Page.php
:
public function createGreeting() {
return 'hi';
}
在我的 Page.ss
模板中,我有变量:<% $createGreeting %>
然而,这正在终止页面。我检查了错误日志,它显示:
PHP message: PHP Warning: Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set. in /usr/share/nginx/html/lungmap/framework/control/Director.php on line 488" while reading upstream, client: 31.210.102.114, server: 52.90.93.59, request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/var/run/php/php5.6-fpm.sock:" 2017/06/12 12:34:50 [error] 1730#0: *6682 FastCGI sent in stderr: "PHP message: PHP Warning: Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set. in /usr/share/nginx/html/lungmap/framework/control/Director.php on line 488
知道是什么原因造成的吗?如果我从 Page.ss
中删除该行,页面加载完全正常。
您不应该将变量包装在 <% %>
块中,而是直接调用它。