Yii2 Url Html format

偶尔善良 提交于 2019-12-11 00:27:38

问题


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 (<a>) 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!