Hello,
I have some php code $_SESSION['username']
and I need to display it using html with something like <p>the username here</p>
. I heard you might be able to do this using echo
in PHP but Im not sure how. Thanks for any help.
Hello,
I have some php code $_SESSION['username']
and I need to display it using html with something like <p>the username here</p>
. I heard you might be able to do this using echo
in PHP but Im not sure how. Thanks for any help.
If I understood you correctly, I believe you are looking for:
<p><?php echo $_SESSION['username']?></p>
echo '<p>' . $_SESSION['username'] . '</p>';
or
<p><?php echo $_SESSION['username'] ?></p>
You should really run it through htmlspecialchars
to avoid breaking your HTML syntax (for example if the user's name contains </p>
or something, or if they attempt an XSS attack):
echo '<p>' . htmlspecialchars($_SESSION['username']) . '</p>';