Dreamweaver Syntax Highlighting in PHP HEREDOC Strings

If you want to use Dreamweaver’s syntax highlighting features in PHP HEREDOC variables you can do it like this:

<?php
$something = 'test';
$output = <<<EOFEOF
<!-- ?> -->
<table><tr><td>{$something}</td></tr></table>
<!-- <?php -->
EOFEOF;
?>

Since you’re in a HEREDOC, PHP will ignore the starting and ending symbols and include them literally in the string, and the user’s browser will ignore them because they’re in HTML comments, but Dreamweaver will think you’re breaking out of the PHP script and assume the string is HTML. Yay! Syntax highlighting in HEREDOCs!

stevekamerman

COO @scientiamobile