0

I need to compare these two strings, so for example:

if($this->getRequest()->headers->get('referer') != $this->generateUrl('foo')) {}

The thing is that the referrer here gives me the full url address:

http://website.com/foo

And the generateUrl() method gives me only the following:

/foo

How can I solve this?

4

1 回答 1

2

您可以使用以下方法生成绝对 url:

 $this->generateUrl('route_name', $parameters, true))

$parameters可以null...查看API参考

于 2013-07-16T14:11:38.380 回答