nested php tages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
samjesse
Forum Newbie
Posts: 2
Joined: Mon Jun 15, 2009 8:05 pm

nested php tages

Post 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.
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: nested php tages

Post 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.
Post Reply