• Home
  • Free WordPress Hosting
Comments RSS Full RSS
acosmin.com

Those Pesky Alternative Control Structures

  • Author: elynn
  • Filed under: Wordpress News
  • Date: Sep 1,2006

I’m sure that if you’ve ever decided to build a theme in WordPress, you’ve had to deal with the The Loop. The Loop is the structure that really is at the heart of the blog engine and looks something like this:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

�.

<?php endwhile; ?>

<?php else : ?>

�.

<?php endif; ?>

(The dots, being the code you use to process each of the individual posts.)

Of course, this is all well and good, but if you’re a beginner to PHP, I’m sure you are a bit confused as to what you are seeing. What are those colons doing there, are where are the curly braces? The answer is that our example is utilizing alternative control syntax in PHP to make the code just a bit more readable. Other templating systems, such as Savant, use this inside templates to make it easier to read where loops and logic statements end. After all endwhile is easier to see at a first glance than a curly brace �}� when reading code mixed with HTML, which describe templates to a ‘T’.


  • RSS feed for comments on this post
  • TrackBack URI


Leave a comment

You must be logged in to post a comment.

Resources

  • Most Recent Wordpress Download
  • Official Wordpress Site

Recent Posts

  • Technology WordPress Theme
  • Won’t somebody think of the children?
  • Premium “Beauty” WordPress theme
  • Personal “Bunny Blog” WordPress Template
  • Play Ball!

Pages

  • Free WordPress Hosting

Archives

  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • June 2007
  • May 2007
  • March 2007
  • December 2006
  • October 2006
  • September 2006

Copyright © 2008 Themepress. All rights reserved | Wordpress theme by Alexandru Cosmin and the Article directory