Welcome to WebmasterWorld Guest from 34.203.28.212

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

print <<<EOF borking a site. Why?

A combo of Dreamweaver + print <<<EOF is killing my site

     
3:02 pm on Jun 16, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 23, 2003
posts:165
votes: 0


Until this week I'd never heard of print <<<EOF but my new employer's websites make heavy use of it across the board.

When I started I downloaded all the files from the server to my work Mac using Dreamweaver MX 2004 and simply edited some HTML on the odd PHP page and uploaded them back to the server once again via Dreamweaver MX 2004 but the whole page disappeared. For some reason the server didn't seem to be liking the


<?php

//loads of PHP here
print <<<EOF

<html goes here />

EOF;
//more PHP code here
?>

and when I changed it to this


<?php

//loads of PHP here

?>

<html goes here />
<?php
//more PHP code goes here
?>

Everything returned to normal. The only explanation I can think of is Dreamweaver is slightly modifying the EOF code. Could this be the case? Otherwise I am completely flummoxed. I've only been PHPing for less than a year so any help would be fantastic, also some explanations of the benefits of Print <<< EOF code would be really helpful.

3:25 pm on June 16, 2005 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12548
votes: 2


Yes, I'm betting DW is the culprit. The syntax you see is called Heredoc [php.net].
5:31 pm on June 16, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 23, 2003
posts:165
votes: 0


I though as much, but I still can't work out what code it has changed exactly.
5:57 pm on June 16, 2005 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12548
votes: 2


You could FTP to the site rather than use DW ;)

There must be a setting in DW that is causing that conversion to happen. You may want to pose the question in the WYSIWYG and Text Code Editors [webmasterworld.com] to see if anybody there can help. Either that or search Macromedia's site for something.

2:10 pm on June 17, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 23, 2003
posts:165
votes: 0


yeah that's my other option I cna sFTP through BBedit. But I'd rather use DW for everything as I prefer it. I'd really like know excatly what changes DW is making. I've posted this question in the WYSWYG forum.
2:17 pm on June 17, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:June 16, 2005
posts:89
votes: 0


One thing to check is to make sure that the closing EOF; is all the way on the left with no whitespace before it (tabs/spaces) otherwise it will not find it.

And for your question of how print <<<EOF is helpful is if you are printing out a lot of html inside of a function that gets called more then once. Otherwise simply putting the html outside of php code works just fine.

5:17 am on June 23, 2005 (gmt 0)

New User

10+ Year Member

joined:May 8, 2003
posts:3
votes: 0


One advantage to the HEREDOC style is that variable inserts in the HTML still happen. Closing the PHP and putting out HTML will NOT do the inserts.

This works:

$stuff = 'hello, world';
print <<< HTML
<P>$stuff</P>
HTML;

3:51 pm on July 7, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 23, 2003
posts:165
votes: 0


fixed. Here's how.

In Dreamweaver> Preferences >Code Format there is an option to indent with 2 spaces automatically checked. Unchecking this solved everything. this was especially confusing as DW didn't appear to show any indentations and the code format looked identical with either settings so be warned.

5:22 pm on July 7, 2005 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12548
votes: 2


I figured there must be a setting in DW that was causing the issue. Glad you got it sorted!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members