jeudi 23 avril 2015

How to echo function in a link php [duplicate]

This question already has an answer here:

So I have a navigation bar, and based on the session the specific links are displayed and I need the list-item to have a class of active.

I have this, however it doesn't make it active, i.e. when it's active the link is dark.

if ('admin' == $_SESSION['username'] ) {
echo "<li echoActiveClassIfRequestMatches('admin')><a href='admin.php'>Admin</a></li>";

function echoActiveClassIfRequestMatches($requestUri)
{
    $current_file_name = basename($_SERVER['PHP_SELF'], ".php");

    if ($current_file_name == $requestUri)
        echo 'class="active"';
}

For some reason for the links that are not being generated with PHP it works fine, but for that link it doesn't.

Aucun commentaire:

Enregistrer un commentaire