Can anyone explain how to make this code work?
echo '<div id="panel1-under">Welcome <?php echo "$_SESSION['username']"; ?></div>';
I've tried removing the single quotes (echo '<div id="panel1-under">Welcome <?php echo "$_SESSION[username]"; ?></div>';
), but it doesn't work.
echo "<div id=\"panel1-under\">Welcome ".$_SESSION['username']."</div>";
or
echo '<div id="panel1-under">Welcome '.$_SESSION['username'].'</div>';
Quick Explain :
PHP is even smart enough to detect variables inside a PHP string and evaluate them :
$variablename = "Andrew";
echo "Hello $variablename, welcome ";
=> Hello Andrew, welcome
More infos : PHP.net - echo