This might be a very simple answer but my brain is absolutely fried. The code I have in place doesn’t display like I want it to. My question is, how would I get the following codes to display properly?
For instance, this code
$toplinks = '<a href="profile.php?id=' . $userid . '">' . $username . '</a> •
<a href="edit_profile.php">Edit info</a> •
<a href="logout.php">Log Out</a>';
Displays perfectly when I echo it out like this
<div id="header"><?php echo "$toplinks"; ?></div>
But this code doesn’t display the same as the $toplinks
echo '$toplinks= "<a href="register.php">Register</a> •
<a href="login.php">Log In</a>';
This is the code I have in place as a whole
<?php
session_start();
$toplinks = "";
if (isset($_SESSION['id'])) {
$userid = $_SESSION['id'];
$username = $_SESSION['username'];
$toplinks = '<a href="profile.php?id=' . $userid . '">' . $username . '</a> •
<a href="edit_profile.php">Edit info</a> •
<a href="logout.php">Log Out</a>';
} else {
echo '$toplinks= "<a href="register.php">Register</a> •
<a href="login.php">Log In</a>';
}
?>
And I try to echo these two out with this
<div id="header"><?php echo "$toplinks"; ?></div>
1 Answer