Page 1 of 1

heredoc problem

Posted: Sun Mar 29, 2009 8:19 am
by simbo
for the life of me i cant get this heredoc to encapsulate the contents..?

Code: Select all

<?php
header("Content-type: text/css");
$color = "green";
 
echo <<<css
 
html { 
    min-height: 100%;
    margin-bottom: 1px; 
}
body {
    background:#000000;
    position: relative;
    text-align: center;
    font-size: 8pt;
    margin: 0px; 
}
 
table.body {
    width: 900px;
}
 
 
 
css;
?>
it looks just like the examples in the manual but fails...?

kind regards
gary

Re: heredoc problem

Posted: Sun Mar 29, 2009 8:31 am
by php_east
posted codes runs fine on me setup.

Re: heredoc problem

Posted: Sun Mar 29, 2009 8:36 am
by simbo
if i move the closing tags up to say line 18 there i can set the table body width with a var,, if i leave as is i cant.. viewed in dreamweaver kinda confirms that moving the closing tags up higher on the page stops the css from becoming highlighted as if php...?

to be clear: in this form the css is not passed... without the heredoc it is passed.... but i need the heradoc to assign vars to the css.... it just seems the heredoc is not correctly setup to me the way it behaves...

Re: heredoc problem

Posted: Sun Mar 29, 2009 8:43 am
by php_east
this works fine too...

Code: Select all

<?php
header("Content-type: text/css");
$color = "green";
 
$css=<<<css
 
html {
    min-height: 100%;
    margin-bottom: 1px;
}
body {
    background:#000000;
    position: relative;
    text-align: center;
    font-size: 8pt;
    margin: 0px;
}
 
table.body {
    width: 900px;
}
 
 
 
css;
 
var_dump($css);
 
?>
sorry i can't be of much help with dreamweaver, never used it.

Re: heredoc problem

Posted: Sun Mar 29, 2009 8:54 am
by simbo
thanks anyway... but it appears dreamweaver is breaking this in some way.. iv read about the importance of a new line before the closing tags,, and i can only guess that dreamweaver is stripping this...

Re: heredoc problem

Posted: Sun Mar 29, 2009 2:00 pm
by califdon
Guess why so many people don't use Dreamweaver?