Php file with styles in all websites

The title might not make too much sense, but what I am trying to do is figure out how to use <?php include('../cdn/examplecss.php') ?> in php but I dont want to put the css file into every different directory. I have different folders each with a index.php but I want to just be able to put <?php include('../cdn/examplecss.php') ?> I know it sounds lazy, but putting a css file (and js) into every directory is a pain considering it will use more space on a computer if you are developing… I hope someone kindly answers this question as I am not very sure.

Normally you’d just leave your static files css, js, images etc in one place and reference those.

ie
yourpage/css/yourfile.css
yourpage/js/yourfile.js

Then wherever you use these just use the absolute path (for the browser)
/css/yourfile.css

prepending the path with a / means the browser will go to the root of the site so it doesn’t matter what directory you’re in.

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service