I needed to use some php code in my css file and did some research online. I found that adding

header("Content-type: text/css"); 

worked. I've been building my site through localhost and started uploading it to me server today. On localhost my style.php file worked as it was supposed to, but when i uploaded it to the server along with all the other files my page was not styled. I wasnt sure if this was because a problem on my end or my webhosting.

1 answer

This was chosen as the best answer

Style.php renders the following error:

Warning: Cannot modify header information - headers already sent by (output started at /mnt/w0105/d13/s07/b030cc78/www/scoobasteve.org/portfolio/style.php:3) in /mnt/w0105/d13/s07/b030cc78/www/scoobasteve.org/portfolio/style.php on line 4

This usually happens when there's extra lines/whitespace or anything else at the beginning of style.php. Make sure that <?php header("Content-type: text/css"); ?> is the very first line in style.php. I see that there's some text above the error message; move that below your php block. Also, many xAMP setups are not set up the same way as your server is, thus the differences in your localhost vs. server.

Answered over 9 years ago by Daryl Claudio