用文本替换PHP [关闭]

I have some PHP that displays the users session name in the HTML and if the user is not logged in, then I would like it to display "User" instead.

Can I have an if statement in this case? I tried it myself but I got header errors.

This is what I've tried so far but each practical attempt just spits out more errors at me.

This is a different approach I have tried.

<?=$_SESSION['sess_user'] or ("User");?>!
<?php echo (isset($_SESSION['sess_user']) ? $_SESSION['sess_user'] : "User"); ?>

This will check if the session is set, if it is then echo the session, if it isn't then it will echo "User".