Yii2 Url Html格式 [英] Yii2 Url Html format
问题描述
快速问题:
我在View Script中使用以下代码来生成链接
< = HTML ::一个( ( $玩家[ '播放'] - >。steam_id_32 ),[ '蒸汽/', 'steamid'=> $播放器[ '播放'] - > steam_id_32])>
这将返回以下链接
/ web / steam / STEAM_0%3A0%3A96553432
如何返回
/ web / steam / STEAM_0:0:96553432
我尝试了一些东西,但无法弄清楚谢谢你
这是行为设计。你不能真的改变这种行为,但你可以使用一种解决方法。
下面的代码首先创建url然后解码它。然后用上一个创建的链接创建链接(< a>
)。
echo Html :: a('title',$ url);
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
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 (<a>
) with the previous created url.
$url = urldecode(Url::toRoute(['steam/', 'steamid' => 'aa:bb:cc']));
echo Html::a('title', $url);
这篇关于Yii2 Url Html格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!