Yii2 Url Html格式 [英] Yii2 Url Html format

查看:125
本文介绍了Yii2 Url Html格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速问题:

我在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆