Posted By

RE666 on 09/22/19


Tagged

includeCSS


Versions (?)

PHP function to load single or multiple CSS files


 / Published in: PHP
 

A simple PHP function to load your CSS files with less code.

In my snippet the default folder containing the CSS files is http://domain.tld/css. Just change the $p variable to any path you need.

+++++ EXAMPLES +++++

for single CSS file: echo inc_css('filename1');

for multiple CSS files: echo inc_css('filename1,filename2,filename3');

  1. function inc_css($files){
  2.  
  3. $p = 'http://domain.tld/css';
  4. $x = explode(',',$files);
  5. $r = "";
  6.  
  7. foreach( $x as $f ){
  8. $r.='<link rel="stylesheet" href="'.$p.'/'.$f.'.css" type="text/css" />';
  9. }
  10.  
  11. return $r;
  12. }

Report this snippet  

You need to login to post a comment.