如何在HTML中编写PHP用户名欢迎消息?

This is my php code to display welcome user into the page if the username and password is correct.

$_SESSION['userName'] = $usernm;
echo "Welcome ".$_SESSION['userName']."!";

I wanted to display the variable name inside this tag, cuz my css coding hav some styles for li and href tags. Please help me...

<li><a href="#">Welcome User!</a></li>

Heres how to echo $_SESSIONS or any php variables inside tag.

You can also add additional if else condition in for $_SESSION to determine whether your session is set or not

<li><a href="#">Welcome <?php  if(isset($_SESSION['userName'])){echo $_SESSION['userName'];}else{ echo 'Session not set';}?>.!</a></li>

Just some simple string concatenation will do

echo "<li><a href='#'>Welcome ".$_SESSION['userName']."!</a></li>";

Check this one:

<?php
$_SESSION['userName'] = $usernm;
?>

<ul>
  <li><a href="#">Welcome <?php echo $_SESSION['userName']; ?>!</a></li>
</ul>

Or maybe this one:

<?php
$usernm = $_SESSION['userName'];
?>

<ul>
  <li><a href="#">Welcome <?php echo $usernm; ?>!</a></li>
</ul>