Can I use file_get_contents to load css?

css, html, php

Solution

This question was posted when I was a beginning developer. I didn't know about Sass and other easier and better ways to achieve variables in CSS. I also didn't know about browser caching.

Jeremy Karlsson answered the question in a comment. `file_get_contents` requires `echo`.

Problem

Instead of this: ``` <head> <link rel="stylesheet" type="text/css" href="css_file.css" /> </head> ``` I want to do this: ``` <head> <style><?php file_get_contents("css_file.css");?></style> </head> ``` For some reason though, the text shows up in the doc but the style is not applied. This is a two part question: - Why is this not working? - Is this a bad idea to do this?

Original source