更新时间:2023-11-19 21:20:28
它们非常相似.
生成一个相对/绝对的路径:
Generates a relative/absolute path :
path('contact')
会生成 /contact
生成方案相对/绝对的url,即域+路径
Generates a scheme-relative/absolute url, ie domain + path
url('contact')
将生成 http://example.org/contact
url() 样式在使用 跨域 ajax 或生成 电子邮件 时很有用,因为主机名不会相同.
The url() style is useful when using cross-domain ajax or generating emails, because the hostname won't be the same.
Take a look at the code https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php for more information