如何在 symfony 的 php 条件下创建到 html 文件的重定向?
How to create a redirect to an html file in a php condition on symfony?
如何在 symfony 的 php 条件下创建到 html 文件的重定向?
我希望如果计数器大于 4,则重定向到 html 页面。
if (count > 4){
// Redirect html file (add html file example.html.twig)
}
试试这个
if (count > 4){
$script = "<script> window.location = 'example.html.twig';</script>";
echo $script;
}
如果您只想从 symfony 渲染一个 html twig 模板,您可以在您的控制器中使用以下内容:
return $this->render('index.html.twig');
https://symfony.com/doc/current/templates.html#rendering-a-template-in-controllers
如果你想重定向到外部 URL:
return $this->redirect('http://whosebug.com');
如何在 symfony 的 php 条件下创建到 html 文件的重定向? 我希望如果计数器大于 4,则重定向到 html 页面。
if (count > 4){
// Redirect html file (add html file example.html.twig)
}
试试这个
if (count > 4){
$script = "<script> window.location = 'example.html.twig';</script>";
echo $script;
}
如果您只想从 symfony 渲染一个 html twig 模板,您可以在您的控制器中使用以下内容:
return $this->render('index.html.twig');
https://symfony.com/doc/current/templates.html#rendering-a-template-in-controllers
如果你想重定向到外部 URL:
return $this->redirect('http://whosebug.com');