How to colour code php in Dreamweaver html files?

Hi all,

OK, I am a total PHP newbie, so apologies for a silly question.

I want to get Dreamweaver to colour code the php code in html files, it does in php files but not the html ones.

Some background…
I have an existing site with Html pages, and want to incorporate php and mysql into it. However I don’t want to lose the work I have done to get ranked in the search engines, so I want to keep the extensions .html .

Now I have added html to application/x-httpd-php in the httpd.conf so that it will show up on the pages.

Thanks in advance

i think the best thing to do is save your files with .php extension and use mod_rewrite to change the extension from .php to .html so they will appear as such to users and search engines.

OR configure extensions somewhere in Dreamweaver I expect, add .html files to the PHP class of files, or whatever the equivalent is.

If you want to switch to the php extension and maintain your search engine rankings, you could use a 301 redirect. This let’s the search engine know you’ve moved the file - and you should keep your rankings.

However, you should also be able to set Dreamweaver to syntax highlight PHP files. I used to use Dreamweaver 8, and I could change the setting there.

In Edit -> Preferences -> Code Coloring, I can change the format for the syntax highlighting to any language regardless of the file extension.

This option should be available on newer versions of Dreamweaver, but it may be located elsewhere in the menu options.

Good luck,

  • Walkere

In order to get Dreamweaver to color PHP code in .html files you will need to move the .html extension into the PHP documenttype.

First, exit Dreamweaver.

You will need to edit at least two Dreamweaver configuration files.
NOTE: I suggest you make backup copies of all files before editing them.

First edit the %dreamweaver install directory%\configuration\Extensions.txt file.
NOTE: %dreamweaver install directory% is the directory you have Dreamweaver installed in.

In my Extensions.txt file, line 2 contained:
Remove the first ,HTML from the line. It should now read:

Then around line 16 you will see the PHP line. Mine was:
Insert the ,HTML after TPL and before the colon. It should now read:

Save the changes.

You may also have a copy of the Extensions.txt in your %USERPROFILE%\Application Data\Adobe|Macromedia\Dreamweaver#\Configuration directory.
NOTE: %USERPROFILE% is your \Documents and Settings\%USERNAME% folder and %USERNAME% is your login name.
NOTE Adobe|Macromedia and Dreamweaver# will vary depending on your Dreamweaver version.
If there is a Extensions.txt file there you can

  • edit it as well
  • copy the Extensions.txt file from your %dreamweaver install directory%\configuration directory over it
  • delete it

Next, you need to edit the %dreamweaver install directory%\configuration\DocumentTypes\MMDocumentTypes.xml file.
On the documenttype id=“HTML” line (line 3 in my file) remove html, from the winfileextension="html, and macfileextension="html, attributes.

Then on the documenttype id=“PHP_MySQL” line (line 75 in my file) add ,html to the end of both the winfileextension="php, and macfileextension="php, attributes. It should look something like:
winfileextension=“php,php3,php4,php5,html” macfileextension=“php,php3,php4,php5,html”

Save the changes.

That’s it. Restart Dreamweaver and .html files are color coded as if they were .php files.

I have to say that I’m really surprised that, considering Dreamweaver is a premium product, it doesn’t already do this by default!

I registered just now to thank you for posting this Dreamweaver CS4 hint. I followed your directions exactly, worked like a champ!!

Now I wish you could solve my other issues with DreamWeaver, like letting me use absolute php include URIs and having the related (ie included) files feature of DreamWeaver work!


By the way, the help files at Adobe talk about using their clunky tag libraries and enabling the php tag libraries for html documents, so the color coding will work correctly when editing an html page that parses php - however, the tag libraries that are canned and assignable to other document types do not include the scripting features within php, just a small handful of php codes like print and echo. I was going crazy wondering how i could edit my html pages that parse php using Dreamweaver CS4, your solution was PERFECT!

One little tip I’d like to add… if you use an editor like notepad to edit these files, don’t forget to run the editor as an administrator on your computer or it may not let you save the changes you made.