PHP“if语句”中的HTML和PHP代码

What if I want to have HTML code inside my 'if' statement, and then php code in the 'else' part? What do I do? I have tried this, but with no luck..

<?php

session_start();

if ($_SESSION['bnavn']) : ?>

   'HTML-code'

<?php else : ?>

    'PHP-code'
    
<?php endif: ?>

I have also tried this, but also with no luck:

<?php

    session_start();

    if ($_SESSION['bnavn']) : ?>

       'HTML-code'

    <?php else : ?>

        <?php 'PHP-code' ?>
        
    <?php endif: ?>

</div>

I have figured it out! I found this link: PHP Session Destroy on Log Out Button

I made the if statement as one of the answers said, and changed my page.html to page.php. I do not know if it have to .php instead of .html, but not it works!