skipping in and out of PHP

When embedding PHP within HTML, you can close your PHP tag whenever you want to output HTML. This enables speedier processing of your PHP. For instance:

<?php if($option_01) { ?>   
    <div class='option_01'>     
    option_01 is chosen   
    </div>
<?php } elseif (option_02) { ?>   
    <div class='option_02'>    
    option_02 is chosen   
    </div>
<?php } else { ?>   
    <div class='option_03'>     
    option_03 is chosen by default   
    </div> 
<?php } ?>

Looks exciting and scary I know but, really, all this is doing is decreasing processor time and usage. PHP checks the options, and steps outside and deals with HTML only if needed. Small savings for the script above, but if this is consistently implemented in larger scripts the savings are worth it.

Advertisements

About Cameron
I'm a final year Computer Science/Information Systems major. Already finished my BA in Politics/Philosophy. I do web and software freelance on the side, while I finish studying. Hoping to be self-employed by the end of my degree, otherwise off into the real-world I go....

One Response to skipping in and out of PHP

  1. amitmondal says:

    Nice tutorial….thanks for this post…..
    Please visit this link for learn more script.
    http://amitmondal.wordpress.com/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: