I found this on a website,
css_loader.php
<?php
// First of all send css header
header("Content-type: text/css");
// Array of css files
$css = array(
'main.css',
'menu.css',
'content.css'
);
// Loop the css Array
foreach ($css as $css_file) {
// Load the content of the css file
$css_content = file_get_contents($css_file);
// print the css content
echo $css_content;
}
?>
Add CSS to the page
<link href="css_loader.php" rel="stylesheet" type="text/css" />
It looks very logical but when i applied it to my page, it didnt work.
is that possible to merge CSS files with this way ?
You have an mistake in your code, here’s the correct code:
And I hope the files are in the same folder. Perhaps you should use
__DIR__ordirname(__FILE__)to get the relative path to your files.