dshafer Posted April 4, 2007 Share Posted April 4, 2007 I have a situation where it would be great if I could have a line of PHP in the HEAD of an HTML document that looks like this: <? include "../css/mainstyle.css"; ?> But when I use that construct, the contents of the CSS file display. Not unexpected, but I wonder if there's any way to do what I want. Thanks. Link to comment https://forums.phpfreaks.com/topic/45506-solved-how-do-i-use-php-include-to-include-a-css-stylesheet-or-can-i/ Share on other sites More sharing options...
Daniel0 Posted April 4, 2007 Share Posted April 4, 2007 Just use: <?php echo "<link rel='stylesheet' href='{$path_to_stylesheet}' type='text/css' />"; ?> or <?php echo "<style type='text/css'>\n"; echo file_get_contents($path_to_stylesheet); echo "\n</style>"; ?> Link to comment https://forums.phpfreaks.com/topic/45506-solved-how-do-i-use-php-include-to-include-a-css-stylesheet-or-can-i/#findComment-221038 Share on other sites More sharing options...
dshafer Posted April 4, 2007 Author Share Posted April 4, 2007 Thanks, Daniel. I should have thought of that. I'm using PHP very little for HTML generation and I obviously paint myself into some corners because of that. Link to comment https://forums.phpfreaks.com/topic/45506-solved-how-do-i-use-php-include-to-include-a-css-stylesheet-or-can-i/#findComment-221442 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.