I want to concatenate in the middle of an echo to write an if statement, is this possible? Here is what I have.
echo \"
Like this, using the ternary operator:
echo "<li class='". (($_GET["p"] == "home") ? "active" : "") . "'><a href='#'>Home</a> </li>";
Do like this:
echo "<li class='".($_GET["p"] == "home" ? 'active' : '') ."'><a href='#'>Home</a> </li>";
Instead of messy inline concatenations, might I suggest getting cozy with printf()?
$format = '<li class="%s"><a href="#">Home</a> </li>';
printf($format, ($_GET['p'] == 'home') ? 'active' : '');
echo "<li class='".(($_GET["p"] == "home") ? "active" : "")."'><a href='#'>Home</a> </li>";