我有一个名为 {$user.login} 的变量,我在这样的 URL 中使用它:
http://profiles.mysite.com/ {$user.login}
我想用 + 符号替换空格,如下所示:
“用户名”变为“用户+名称”。
这样,我的链接会更干净。
而不是http://profiles.mysite.com/User%20name我会有http://profiles.mysite.com/User+name
我有什么办法可以做到这一点?谢谢!
我有一个名为 {$user.login} 的变量,我在这样的 URL 中使用它:
http://profiles.mysite.com/ {$user.login}
我想用 + 符号替换空格,如下所示:
“用户名”变为“用户+名称”。
这样,我的链接会更干净。
而不是http://profiles.mysite.com/User%20name我会有http://profiles.mysite.com/User+name
我有什么办法可以做到这一点?谢谢!
PHP 函数urlencode将空格转换为+
符号。
尝试: http://profiles.mysite.com/{$user.login|urlencode}
在您的模板中。