micky micky - 1 year ago 75
PHP Question

Passing the user id as parameter

I am trying to pass the id of the user who is logged in as a parameter to the index.

<li class="active"><a href="<?php echo Yii::$app->request->baseUrl;?>/todo/index/"><span class="glyphicon glyphicon-home"></span> Home</a></li>

here i want to add the user id who is logged in:

what i have tried to fail:

<li class="active"><a href="<?php echo Yii::$app->request->baseUrl;?>/todo/index/. Yii::$app->user->identity->username ."><span class="glyphicon glyphicon-home"></span> Home</a></li>

Answer Source

You can do like this

<li class="active">
    <a href="<?php echo Yii::$app->request->baseUrl.'/todo/index/'.Yii::$app->user->identity->username;?>">
        <span class="glyphicon glyphicon-home"></span> Home
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download