Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9178303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:31:12+00:00 2026-06-17T17:31:12+00:00

I’ve always been one to write clean and readable code. With that said, I’ve

  • 0

I’ve always been one to write clean and readable code. With that said, I’ve not been able to find out whether or not there’s any difference in processing speed when using more or less <?php tags. Here’s some code for comparison:

PREFERRED CODE:

<?php while($condition): ?>
    <?php if($anotherCondition): ?>
        Hello world!
    <?php endif; ?>
<?php endwhile; ?>

SHORTER CODE:

<?php while($condition):
    if($anotherCondition): ?>
        Hello world!
    <?php endif;
endwhile; ?>

You see in the second code I use only two <?php tags, but I find the first code block much easier to follow. Is there any loss in efficiency because I used more <?php tags?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:31:13+00:00Added an answer on June 17, 2026 at 5:31 pm

    There is a performance implication but it is likely negligible. Any space or tab that is not inside a <?php ?> block will be sent as part of the output of the PHP script. To understand this consider this simple example:

    The PHP code:

    <?php while($condition): ?>
        <?php if($anotherCondition): ?>
            Hello world!
        <?php endif; ?>
    <?php endwhile; ?>
    

    Gets sent across the wire as

    \n
    \t\n
    \t\tHello world!\n
    \t\n
    \n
    

    While this PHP:

    <?php while($condition):
        if($anotherCondition): ?>
            Hello world!
        <?php endif;
    endwhile; ?>
    

    Returns this:

    \n
    \t\tHello world!\n
    \n
    

    This is not the kind of thing you really want to worry about though, I say go for readable code. I will say however that your first example involves a lot of extra typing, are you sure it’s better?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.