Forum Moderators: coopster

Message Too Old, No Replies

css @import a PHP file, header problem

Initializing an object in the imported file seems to output something

         

lars stecken

9:15 am on Sep 18, 2003 (gmt 0)

10+ Year Member



Hi,

it's a somewhat exotic topic but maybe someone can hint me in the right direction. Here's my problem:

I want to import a dynamically created stylesheet which of course is generated in a PHP script. Within this script the following happens:

***************************************
include_once("someclass.php");
header("Content-Type: text/css");
$myobj= & new obj;
$css = $myobj->getCSS();
/*Just to test if it works at all I use these lines
$css = 'body {
background-color:silver;
}';
*/
echo $css;
**************************************

Everything works fine as long as I do not initalize my object (which has a couple of parent objects).
It seems the initialization process of chained constructors screws up the header information. First I thought that may be something is outputting some PHP warning or a notice but I think I ruled that out....

Can anybody provide any information about this?

I know that I could probably work my way around it, but it would be beautiful if I was able to achieve it this way.

Thanks for your help,
Stefan

coopster

2:39 pm on Sep 18, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Your
include_once("someclass.php");
isn't producing any output, is it? Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called.

lars stecken

6:35 pm on Sep 18, 2003 (gmt 0)

10+ Year Member



No, the first include doesn't produce any problems. But actually I haven't checked all the other files that are included in the first include for any whitespace.

Let me check that...