gpt4 book ai didi

symfony - 在 Symfony2 中,如何在 Controller 内重定向到带有 anchor 标记/哈希的 URL

转载 作者:行者123 更新时间:2023-12-02 08:43:07 25 4
gpt4 key购买 nike

我在 Controller 中,我想重定向回某个 URL,例如/home/news/example#comment1423

如何将哈希值添加到返回参数中?

return $this->redirect(
$this->generateUrl("news_view", array("permalink" => "example"))
);

最佳答案

最简单的解决方案可能是串联:

$url = $this->generateUrl("news_view", array("permalink" => "example"));
return $this->redirect(
sprintf('%s#%s', $url, 'comment1423')
);

关于symfony - 在 Symfony2 中,如何在 Controller 内重定向到带有 anchor 标记/哈希的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7724082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com