Php – phtml, and when should I use a .phtml extension rather than .php

file extensionPHP

I'm wondering what the difference between .phtml and .php files is, and when to use one over the other.

Best Answer

There is usually no difference, as far as page rendering goes. It's a huge facility developer-side, though, when your web project grows bigger.

I make use of both in this fashion:

  • .PHP Page doesn't contain view-related code
  • .PHTML Page contains little (if any) data logic and the most part of it is presentation-related