micky micky - 3 months ago 6x
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>


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