Q:

PHP syntax misinterpretation

Okay, I'm currently confused as to what the best way to write the code below. I'm confused about how to escape an echo to include more php then carry on the same echo. I sort of understand you need to use double and single " and '. I've included a screenshot of what shows up in chrome when viewing the source as well as the code below.
I managed to get this working on another page, but using the same method it doesn't seem to work on this page.
<?php echo "You are logged in as " . $_SESSION['user_name'] . "." ?>  

Any pointers or direction on where I'm going wrong would be appreciated, even if only in example format.
My image showing what is output - http://i.imgur.com/4EaTxP8.png
<?php session_start(); ?>
<?php if(isset($_SESSION['user_name']) && !empty($_SESSION['user_name'])){
echo "<!doctype html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>test</title>
<link rel='stylesheet' type='text/css' href='style.css'>
</head>
<body>
<div>
'.include 'inc/sidebar.php'; .'
<div id='content-wrapper'>
<div class='page-content'>
'.include 'inc/headerbar.php';.'
'.include 'inc/settings.php';.'
</div><!-- End Page Content -->
</div><!-- End Content Wrapper -->
</div><!-- End Page Wrapper -->
</body>
</html>";
}
else{
echo "You aren't logged in.";
} ?>

A:

Try something like this:
<?php session_start(); ?>
<!doctype html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>test</title>
<link rel='stylesheet' type='text/css' href='style.css'>
</head>
<body>
<?php if(isset($_SESSION['user_name']) && !empty($_SESSION['user_name'])): ?>
    <div>
        <?php include 'inc/sidebar.php'; ?>
        <div id='content-wrapper'>
            <div class='page-content'>
                <?php include 'inc/headerbar.php'; ?>
                <?php include 'inc/settings.php'; ?>
            </div><!-- End Page Content -->
        </div><!-- End Content Wrapper -->
    </div><!-- End Page Wrapper -->
<?php else: ?>
    You aren't logged in.
<?php endif; ?>
</body>
</html>

This kind of code remembers me the days when we feared the Y2K bug...

