PHP Heredoc Color Coding Fix in Adobe Dreamweaver

* Dreamweaver CC 2017 Update - This doesn't appear to be working for the CC2017 release of Dreamweaver. They completely rewrote the editor and color-coding has been dramatically altered. Adobe has said they are considering putting color-coding back the way it was or at least updating the new method so it works like the old one. I'll update again if they change anything.

Even though I rarely use Adobe Dreamweaver's Design Mode, I still rely on it daily for most of my web development coding. There is just something familiar and comfortable in the code coloring, shortcuts, and file management system.

That being said, one of the most common code constructs I use in my web projects is PHPs Heredoc string delimited convention.

Here's a link to the Heredoc PHP documentation:

It looks something like this:

$strHtml = <<<EOM
<p>Example of string
spanning <strong>multiple lines</strong>
using <em>heredoc</em> syntax.</p>

I personally use EOM as my marker, but others frequently use EOF, END, EOT, etc.

The problem with using this kind of delimiter in Dreamweaver though, is that it will break the color coding. HTML or Javascript inside the Heredoc tags is not colored correctly and all the PHP after the tags is often messed up.

There is a relatively easy fix though. We can update the color coding configuration files in Dreamweaver to ignore the Heredoc tags and color code everything inside them as if they weren't there.

First, you need to locate the PHP.xml file. In my installation of Dreamweaver CC 2015 on Windows 10, it is located here:

C:>Program Files>Adobe>Adobe Dreamweaver CC 2015>Configuration>CodeColoring>PHP.xml

Open this in your favorite text editor. You will probably need to be an Administrator to edit this file depending on your system set up.

There are a series of <blockStart>...</blockEnd> sections at the beginning of the file. The last one is at around line 18.

After this line:


Add the following:

<blockStart doctypes="PHP_MySQL" scheme="customText"><![CDATA[<?php\s]]></blockStart>
<blockStart doctypes="PHP_MySQL" scheme="customText"><![CDATA[<?php\n]]></blockStart>
<blockStart doctypes="PHP_MySQL" scheme="customText"><![CDATA[EOM;]]></blockStart>

Note you will need to change the three 'EOM' references if you use a different tag in your script. If you use more than one, you will need to add these lines for each variation.

That's it! Save the file and restart Dreamweaver. Your color coding should now be doing what you expect it to do.