heredoc problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simbo
Forum Newbie
Posts: 3
Joined: Sun Mar 29, 2009 8:15 am

heredoc problem

Post 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
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: heredoc problem

Post by php_east »

posted codes runs fine on me setup.
simbo
Forum Newbie
Posts: 3
Joined: Sun Mar 29, 2009 8:15 am

Re: heredoc problem

Post 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...
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: heredoc problem

Post 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.
simbo
Forum Newbie
Posts: 3
Joined: Sun Mar 29, 2009 8:15 am

Re: heredoc problem

Post 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...
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: heredoc problem

Post by califdon »

Guess why so many people don't use Dreamweaver?
Post Reply