What is phtml, and when should I use a .phtml extension rather than .php?

后端 未结 6 1879
逝去的感伤
逝去的感伤 2020-12-04 05:57

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

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 06:42

    You can choose any extension in the world if you setup Apache correctly. You could use .html to do PHP if you set up in your Apache config.

    In conclusion, extension has nothing to do with the app or website itself. You can use the one you want, but normaly, use .php (to not reinvent the wheel)

    But in 2019, you should use routing and forgot about extension at the end.

    I recommend you using Laravel.

    In answer to @KingCrunch: True, Apache not use it by default but you can easily use it if you change config. But this it not recommended since everybody know that it not really an option.

    I already saw .html files that executed PHP using the html extension.

提交回复
热议问题