PHP Includes Bug in Dreamweaver CS3

I have a love hate relationship with WYSIWYG editors. Historically they’re great for “quick and dirty” sites but crash and burn with all their bloated add-ons when you need to do any back end programming. However, I must say, Adobe Dreamweaver CS3 is a huge improvement over Dreamweaver 8 but there are still some problems with it interpreting PHP.

The Problem
I opened an existing website I created with PHP/mySQL and CSS in Dreamweaver CS3 and immediately noticed Dreamweaver didn’t interpret the include(); function correctly. Dreamweaver neglected to include my header.php file which contains my CSS link (amoung other crucial elements) thus, the entire site lacked my formatting in the design view. I thought, “that’s odd considering Dreamweaver has a PHP code insertion tab with the include() function”. Then I noticed my footer.php file was showing up in Dreamweaver. Now I am getting angry.

It turns out, Dreamweaver does not correctly interpret the include function if there is any other code in the PHP script.

For example, Dreamweaver would be baffled by the following simple script:

< ?php
$title = "Home page";
include("includes/header.php");
?>

Dreamweaver would not include the header.php file in the above senario. However, if you breakup the code into two scripts:

< ?php
$title = "Home page";
?>


< ?php
include("includes/header.php);
?>

Dreamweaver will correctly interpret the PHP script and include your header.php file. What a headache.

< –UPDATE–>
I should note that the problem for me is not so much viewing the webpage correctly in the Dreamweaver preview pane (I use a test server for that), it’s more that I want to have the nifty auto suggest feature work for my attached CSS styles. The CSS stylesheet link is in my header.php file so unless I chunk my code like the above example, Dreamweaver doesn’t see that I have an attached CSS stylesheet.