If I add some php code to a .html
or .htm
file in PhpStorm, the code style for that bit of php code is NOT the same as in .php
file.
For instance, here is the same code in two different file formats:
How can I get the php code segment inside of the .htm
to look like it does in a .php
file?
UPDATE
The reason I want php code styling within an htm file is because I am using October CMS. October CMS uses a .htm file extension which is divided into three section. One of those section is for php code. What I want to know is how can I get the php content code which resides in the htm file to use my php code styles within PhpStorm.
In order for PhpStorm to recognize and highlight PHP code in any file such file MUST be associated with "PHP File" file type and have PHP icon next to file name.
By default .htm
/.html
files are associated with "HTML Files" file type.
Few possible solutions:
.php
.phtml
file extension -- which is commonly used extension for such cases (in general denotes that this file is a "template" -- a HTML file mixed with PHP instructions)Associate .htm
(or whatever else extension you want) with "PHP File" file type.
For that: Settings/Preferences | Editor | File Types
-- find "PHP File" and add appropriate pattern (e.g. *.htm
). IDE will ask if you want to remove such pattern from existing/default "HTML File" to this "PHP File".
Possible downside: some HTML inspections may not be triggered (relaxed) in PHP file.
NOTE: Such association is IDE-wide and affects ALL projects.
The best/most neutral solution overall is #2 -- use dedicated file extension for such files (*.phtml
is a most commonly used).