my php code doesn't work inside a li tag.
I tried several things but it doesn't work.
echo '<li $page_title=="Cart" ? "class="nav-item active"" : "">';
I don't understand why it doesn't work, can someone help me with this code?
You can't execute php code inside of single quotes, and you can't do ternary operators inside of double quotes or single quotes. Store it in another variable and run it that way.
$class = ($page_title=='Cart') ? "class='nav-item active'" : '';
echo "<li $class>";