-1

I'm building an interactive website (with CMS) and I'm running into some trouble. I want to make an image carousel, but for that I want to change the background. I had a CSS file, named style.css, and converted it to a PHP file, style.php. After the change of extension, I used <?php header('Content-type: text/css') ?>. Unfortunately, my CSS just degraded to an older version of CSS, not CSS3.

So, how can I upgrade my style.php so I can use CSS3, and is there a better way for making the carousel?

TylerH
  • 20,799
  • 66
  • 75
  • 101
acyclone
  • 9
  • 3
  • If you are using IE, try this header also: `header("X-Content-Type-Options: nosniff");` - put after the CSS header, it tells IE, "Yes. I know what I mean with the previous header, don't try to correct me." Also, check the error logs - are you getting an error that text was sent before the header? – kainaw Jul 23 '15 at 18:09
  • No, sorry... It doesn't work at all... And I don't get any error messages... – acyclone Jul 23 '15 at 18:16
  • 2
    CSS file is just a text file with styling infos. If the browser can handle CSS3, then CSS3 will work. How do you call style.php in your html and what is the content of style.php? And what do you mean by degraded to older version ? – frz3993 Jul 23 '15 at 18:17
  • index.php `` – acyclone Jul 23 '15 at 18:20
  • Why don't you post an example of the CSS you are seeing, and then an example of the CSS you were expecting. – Jamie Bicknell Jul 23 '15 at 18:22
  • Images are coming up... – acyclone Jul 23 '15 at 18:23
  • I need 10 reputation... – acyclone Jul 23 '15 at 18:31
  • First thing, why are you treating the CSS file as a php file, why not just leave it as the CSS file? Secondly, CSS3 just contains newer sets of selectors and properties, a CSS file can't be "degraded" to an earlier CSS version — as @frz3993 says, it's just a text file with styling rules and the browser is what decides if a rule will work or not. Thirdly, the only way someone will be able to help you is if you can post the actual code you're using as per Jamie Bicknell's request. Maybe you aren't even writing the CSS correctly in the first place? – bjornmeansbear Jul 23 '15 at 18:32
  • I don't like the title – Bader Jul 23 '15 at 18:36
  • Just did a quick test with my web app, changed my css extension to `.php`. Will not work without the header but worked with the content-type header. I think you're missing a semicolon there. My suggestion, if you're trying to change the styles base on certain conditions, make PHP change the css file not using PHP to provide the style. – frz3993 Jul 23 '15 at 18:40
  • First, I want my background (from the carousel) to be an image, so I want the background to be dynamic. Secondly, maybe the css inside the php installed on my mac - I'm hosting from my localhost - isn't the latest version. And last, it has nothing to do with my css writing, because I already had written my css. Later, when I converted into php, most of the elements changed. – acyclone Jul 23 '15 at 18:42
  • I used a semicolon in my code (what I was forgotten in the example above) – acyclone Jul 23 '15 at 18:44
  • And change the `src` to `href`. – frz3993 Jul 23 '15 at 18:45
  • If I do that, there won't be any CSS implemented... – acyclone Jul 23 '15 at 18:46
  • There are a few problems with your question, acyclone. **First**: you mention wanting to make a carousel, but then change topics to converting PHP to CSS, then at the end you ask for advice on improving your carousel. What carousel? Do you have code? If so, please include it in your post. **Second**, it's unclear what you mean by "upgrading PHP to CSS3". CSS3 files are the same as CSS1 or CSS2 files. The only difference is the contents within the file, e.g. CSS3 supports newer selectors. **Third**, CSS doesn't "upgrade" or "downgrade". It remains exactly as you've written it. – TylerH Jul 23 '15 at 18:48
  • "css inside the php installed on my mac" - I'm not sure you entirely know how CSS works and how it's different from PHP. – Jamie Bicknell Jul 23 '15 at 18:49
  • I don't remember `link` tags having `src` attribute @acyclone. Correct me if I'm wrong. – frz3993 Jul 23 '15 at 18:51
  • I know the difference guys. I'm working with html, php, javascript, jQuery, and css over five years now! I'm not stupid! – acyclone Jul 23 '15 at 18:52
  • sorry, your right... link elements only work with href not src... – acyclone Jul 23 '15 at 18:53
  • Sorry, I don't mean to be rude it's just the wording you've used rang some alarms. Anyway, caching is the next thing you need to look into. If you clear your cache does it show the correct CSS? if so, then you'd need to add some headers in the PHP file to tell the browser how to cache the file. – Jamie Bicknell Jul 23 '15 at 18:56
  • This is what i get: `Warning: Cannot modify header information - headers already sent by (output started at /Users/********/Sites/stylesheets/style.php:2) in /Users/********/Sites/stylesheets/style.php on line 2
    `
    – acyclone Jul 23 '15 at 19:01
  • That error means that there is something being output before your header() function. This could be text or whitespace, make sure that there is nothing being output in that file before your header() call. – Jamie Bicknell Jul 23 '15 at 19:03

1 Answers1

0

The problem was the comment (/* php header */) before the header... Thank you guys

acyclone
  • 9
  • 3