0

This question already has an answer here:

This is a code set I copied from Twentyeleven theme.

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

        <?php get_template_part( 'content', get_post_format() ); ?>

        <?php endwhile; ?>

        <?php twentyeleven_content_nav( 'nav-below' ); ?>

Why do developers use many opening and closing PHP tags when developing WordPress themes?

Above code can be written like this.

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

        get_template_part( 'content', get_post_format() );

        php endwhile;

        twentyeleven_content_nav( 'nav-below' ); ?>

So what is the purpose of using opening and closing php tags for almost every line?

marked as duplicate by Mark Kaplun, fuxia Feb 11 '15 at 6:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    matter of personal choice I guess. Not limited to WP devs. – Sisir Feb 11 '15 at 6:25
  • This is the wrong place to ask this (also because questions about a specific theme are off-topic), but you should be able to get on the official wordpress "chat" and just ask the people that wrote the code. – Mark Kaplun Feb 11 '15 at 6:28
0

Everyone has got his/her own style of writing code. Personally, I believe that using different opening and closing PHP tags makes the code easy to read and understand. Theme files carry both PHP as well as HTML code, so keeping the code clean in order to make it easy to read becomes important. Adding HTML in between also becomes easy if you separate your PHP statements.

That apart, I don't think there is any performance compromise if you use PHP open and close tags (please correct me if I'm wrong here). So, why not?! :-)

Not the answer you're looking for? Browse other questions tagged or ask your own question.