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 5844297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:16:22+00:00 2026-05-22T12:16:22+00:00

I have a file with php and html codes mixed, like this: echo <tr

  • 0

I have a file with php and html codes mixed, like this:

echo "<tr class='somthing'>";

What is the best way to keep my php files with only php code?

  • 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-22T12:16:22+00:00Added an answer on May 22, 2026 at 12:16 pm

    There is some contention about this, so I will simply say that whatever you choose, stick with it.

    Generally, you can use a templating system (e.g., Smarty) to keep your files formally clean of PHP code, but this has some drawbacks in the speed department.

    Alternatively, you can use minimal code by breaking out the display related portions and using small PHP snippets therein, e.g.

    <?php foreach ($myArray as $myElement): ?>
    <tr>
        <td><?php echo $myElement; ?></td>
    </tr>
    <?php endforeach; ?>
    

    Of course this doesn’t completely separate your code from your HTML, but that’s nearly impossible to do for anything nontrivial; in my opinion, Smarty templates are just different code, not the absence of code. This approach is advocated by some frameworks such as codeigniter and Zend Framework (thought you can use them with Smarty as well, it is not the default).

    One important thing to remember is that your display logic is just that: logic. Whatever method you choose, you will never be 100% free of code (or code-like markings which are interpreted by other code/applications) in the display until you use static-only displays.

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

Sidebar

Related Questions

I have written jQuery code, in files Main.html and ajax.php . The ajax.php file
I have 3 files 1) show_createtable.html 2) do_showfielddef.php 3) do_showtble.php 1) First file is
I have a .php file with HTML code also in it. Through this file
I have this html form which calls a php file . The index.html ->
OK i have 2 files one is index.php and the other is file.html now
I have two PHP files: template.php template.html.php The first is the class definition for
I have a HTML file and a PHP file in the same folder on
First I have a PHP file that gets data and file from a HTML
I have a file called 34.php?session=2534464a39a2c97cb7113689726a4e52 in my /var/www/html folder but I can't view
I'm new to DOM parsing in PHP: I have a HTML file that I'm

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.