Page 1 of 1

nested php tages

Posted: Fri Jun 19, 2009 3:14 am
by samjesse
Hi
I have the following code which I fee has too many php tags and would like to know if it can be simplified a bit.

thanks

Code: Select all

<div id="page">
    <?php if ($sel_page) { ?>
        <h2><?php echo htmlentities($sel_page['menu_name']); ?></h2>
        <div class="page-content">
            <?php echo strip_tags(nl2br($sel_page['content']), "<b><br><p><a>"); ?>
        </div>
    <?php } else { ?>
        <h2>
            <?php
                echo "Welcome to " . BUSINESS_NAME; // stored in functions.php
            ?>          
        </h2>
    <?php } ?>
</div>
sorry, I could not find out how to make the code more colorful to read easily.

Re: nested php tages

Posted: Fri Jun 19, 2009 4:17 am
by jazz090
code actually looks pretty good to my opinion because otherwise you have to use echo and its gets a bit messy. if i was coding that, i would write it like that.