yii2 原生html,Yii2 Url Html format

本文介绍了如何在Yii2中避免URL链接的自动编码,通过urldecode函数绕过设计限制,实现生成STEAM_0:0:96553432格式的Steam ID链接。StackOverflow上的解决方案提供了解决思路。
摘要由CSDN通过智能技术生成

问题

Quick Question:

i use following code in my View Script to generate a link

=HTML::a("(".$player['player']->steam_id_32.")",['steam/','steamid'=>$player['player']->steam_id_32])?>

This is going to return following link

/web/steam/STEAM_0%3A0%3A96553432

how can i have it return

/web/steam/STEAM_0:0:96553432

i tried some thing but could not figure it out thank you

回答1:

This behavior is by design. You can't really change this behavior, but you could use a workaround.

The code below first creates the url and then decodes it. Then create the link () with the previous created url.

$url = urldecode(Url::toRoute(['steam/', 'steamid' => 'aa:bb:cc']));

echo Html::a('title', $url);

来源:https://stackoverflow.com/questions/26360249/yii2-url-html-format

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值