What is a .phmtl file?


#1

in the skeleton app on official github it has: https://github.com/slimphp/Slim-Skeleton/blob/master/templates/index.phtml is a .phtml file simple the file extension used for twig templating or something else?


#2

Twig templates usually have a .twig or .html.twig extension. Files that include a mix of html and php often use a .phtml extension.


#3

makes sense, many thanks, never seen that before and it just seemed somewhat a long file name extension considering the majority are 3 letters with the exception of .html surprised to see an added letter added additionally have it be picked up by web server.


#4

Long, long ago when PHP was known as PHP/FI (version 2.0), .phtml was the accepted extension for pages with PHP code to be parsed.


#5

But is it still a standard that is to be used? I am now slightly confused as to whether it is or not?


#6

It is totally up to you. Most people will use .php for any PHP file, regardless if it contains HTML. If it is a Twig template with HTML, most people will use .twig or .html.twig. But it is your choice. Most people don’t use .phtml these days. You still see it frequently, but it isn’t common for newer projects.


#7

It is a file ext that some folks used for a while to denote that it was PHP generated HTML. As servers like Apache don’t care what you use as a file ext as long as it is mapped to something, you could go ahead and call all your PHP files .jimyBobSmith and it would happily run them. PHTML just happened to be a trend that caught on for a while.