phpif-statementechorequest-uri

class within an div using php echo


Just basically want to know if its possible adding an class to my div which i echo using an if statement.

My code:

$currentpage = $_SERVER['REQUEST_URI'];

if ($currentpage == "/room/penthouse-suite/"){
echo "<div class="' .text-center text-emphasis text-lg. '">test 
penthouse</div>";
}
elseif ($currentpage == "/room/garden-room/"){
echo "<div class="text-center text-emphasis text-lg">test garden</div>";
}
elseif ($currentpage == "/room/ocean-suite/"){
echo "<div class='text-center text-emphasis text-lg'>test ocean</div>";
}
elseif ($currentpage == "/room/mountain-suite/"){
echo "<div class='text-center text-emphasis text-lg'>test mountain</div>";
}

As you can see i did try a couple of ways, but not getting it working.


Solution

  • SOLVED

    Basically just used single quotes in side the double quotes.(easy)

    if ($currentpage == "/room/penthouse-suite/"){
    echo "<div class='text-center text-emphasis text-lg'>test 
    penthouse</div>";
    }
    elseif ($currentpage == "/room/garden-room/"){
    echo "<div class='text-center text-emphasis text-lg'>test garden</div>";
    }
    elseif ($currentpage == "/room/ocean-suite/"){
    echo "<div class='text-center text-emphasis text-lg'>test ocean</div>";
    }
    elseif ($currentpage == "/room/mountain-suite/"){
    echo "<div class='text-center text-emphasis text-lg'>test mountain</div>";
    }