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.
Adrian 4:30 pm on August 16, 2007 Permalink
That… is ridiculous. Well, at least now we know. Thanks!
Mike Olbinski 9:56 pm on August 16, 2007 Permalink
I hand-code everything….you crazy kids with your fancy shmancy toys!
That is kind of cool though Ryan…I didn’t think there would be a web development tool that would actually include a file in development mode.
Grant Gittus 3:46 am on January 31, 2008 Permalink
It may be more involved than that. I have little experience with php, and am just getting up to speed with Dreamweaver (after using GoLive for a few years).
There’s a site I am building at the moment which has a Spry menu bar in one file loaded into the other pages with a call.
If I place a DW php include ‘object’ in the page, the site breaks as it can’t find the required directory (??!). However, if I cut & paste the same code I used in GoLive, the site functions perfectly BUT DW’s page display goes completely FUBAR: all you can see is the menu text – all other content disappears.
Still trying to find out why.
Jazz 11:48 am on February 28, 2008 Permalink
I never use dreamweaver for the design view, it takes just as much time to upload the file to my site and look at it there. I guess if you don’t have a domain you can test things on this is a problem but really I could care less if the design view doesn’t work perfectly with php. I like dreamweaver for its code view where it auto completes redundant html tags and color codes different tags/functions making it very clean and easy to read.
Roll 9:10 am on July 7, 2008 Permalink
This used to work in Dreamweaver MX. It is a new “bug” if you will. All you people who suggested workarounds are very helpful, and thanks! Still, it is completely lame that CS3 works like this! It’s not like includes and CSS are arcane or high level programming. I’m very suprised the developers let this one slip through. I am hoping they issue a bug fix soon.
Miki 11:56 pm on July 17, 2008 Permalink
Dreamweawer some time sucks try Aptana studio it’s free. I’m combine Apatana php and javascript editor with Dreamweaver visual and code html editor.
Greg Eyton-Jones 6:25 pm on February 23, 2009 Permalink
I seem to be having problems with my php in dreamweaver. I am new to php and would like to include an external sheet. My code is correct and I know that it is although when I preview it its as if there is no include at all.
Matthew Shapiro 8:57 pm on May 12, 2009 Permalink
I can happily report that DW CS4 also has this bug. But I agree with Jazz. DW is great for its code view, and if you have a mac, its very easy to create your own testing server by “turning on” apache, mysql and php (all included with Leopard). I’m sure it would be easy to do this with a PC too.
luca 4:09 am on December 11, 2009 Permalink
hi, i report to this forum that i have the same problem on cs4, dww doesn’t let me see the web page with includes in design mode. I’ve report this bug on adobe web site
d 1:37 pm on December 13, 2009 Permalink
Thanks man – exactly the answer I needed.
Broke it out into two scripts and it worked.