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

  • SEARCH
  • Home
  • 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 663111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:27:12+00:00 2026-05-13T23:27:12+00:00

This may be a silly question, but as someone relatively new to PHP, I’m

  • 0

This may be a silly question, but as someone relatively new to PHP, I’m wondering if there are any performance-related issues to frequently opening and closing PHP tags in HTML template code, and if so, what might be best practices in terms of working with PHP tags?

My question is not about the importance/correctness of closing tags, or about which type of code is more readable than another, but rather about how the document gets parsed/executed and what impact it might have on performance.

To illustrate, consider the following two extremes:

Mixing PHP and HTML tags:

<?php echo
   '<tr>
       <td>'.$variable1.'</td>
       <td>'.$variable2.'</td>
       <td>'.$variable3.'</td>
       <td>'.$variable4.'</td>
       <td>'.$variable5.'</td>
   </tr>'
?>
// PHP tag opened once

Separating PHP and HTML tags:

<tr>
   <td><?php echo $variable1 ?></td>
   <td><?php echo $variable2 ?></td>
   <td><?php echo $variable3 ?></td>
   <td><?php echo $variable4 ?></td>
   <td><?php echo $variable5 ?></td>
</tr>
// PHP tag opened five times

Would be interested in hearing some views on this, even if it’s just to hear that it makes no difference.

Thanks.

  • 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-05-13T23:27:13+00:00Added an answer on May 13, 2026 at 11:27 pm

    3 simple rules for you to get it right:

    • No syntax issue can affect performance. Data manipulation does.
    • Speak of performance only backed with results of profiling.
    • Premature optimization is the root of all evil

    Performance issues are quite hard to understand. It is advised for the newbies not to take it into account. Because they are always impressed with trifle things and fail to see a real important things. Just because lack of experience.

    Same for your question. Imagine you’ll ever get some difference. Even big one, say, one method is 2 times faster. Oh my, 2 times! I choose it and optimized my app well, it will run 50% faster now!

    Wrong. Not 50%. You’d never notice or even measure this speed increase. Because you optimized a part that take only 0,0001% of whole script runtime.

    As for the big HTML tables, it take a long time for the browser to render it. Much more than you took to generate.

    Profiling is a key word in the performance world. One can trash any performance related question with no doubts if there is no word "profiling" in it.
    At the same time profiling is not a rocket science. It’s just measuring of runtime of different parts of your script. Can be done with some profiler, like xdebug, or even manually, using microtime(1). And only after detecting the slowest part, may you start with tests.

    Learn to profile before asking performance questions.
    And learn not to ask performance questions if there is no real reasons for it.

    Premature optimization is the root of all evil – D.Knuth.

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

Sidebar

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.