2015-09-09 21 views
5

我是Yii2的新手。请帮我实现这一点。我想知道如何在yii2中创建absoluteurl。我已经尝试了下面给出的代码,但我想要不同的东西。如何在yii2中传递两个参数createabsoluteurl

echo Yii::$app->urlManager->createAbsoluteUrl(['site/confirm', 'id' => $user->id,'code' => $user->token,'&']); 
output is http://car-rental.demoinja.com/site/confirm/69?code=275a9253dfc81efa47be4fdf1fc6a927&1=%26 

但我想要的网址这样

http://car-rental.demoinja.com/site/confirm/?id=69&code=275a9253dfc81efa47be4fdf1fc6a927 

回答

3

无需在createAbsoluteUrl函数添加 '&';所以你需要使用以下功能。

<?php echo Yii::$app->urlManager->createAbsoluteUrl(['site/confirm', 'id' => $user->id,'code' => $user->token]); ?> 
+0

好的。让我检查一下。 –

+0

输出是相同的 'http://car-rental.demoinja.com/site/confirm/72?code = afde716505a995ec5e5a50f78e2721b5' –

+0

检查'webManager.php'中的'urlManager'配置。并检查你的网址规则。 – GAMITG