Adding global CSS via index.php

Various websites that were built with PHP have a index.php file.

If I have access to this file, can I add some global CSS code from it?

I know it would sound strange, but is it possible to disgustingly and abhorrently add CSS that would effect a website globally, from it’s index.php file?

Thanks :face_vomiting: :slight_smile:

You can have an external style sheet <link rel="stylesheet" media="all" href="assets/css/stylesheet.css"> that’s basically global.

Oh, must it be a separate file? can’t I append (say, with a heredocument) an HTML codepiece added to <head> with some in-file CSS?

Theoretically you can add any kind of client side code with PHP.

But this is one of those questions where we must ask what your actual intention is, as it may be you are asking the wrong question to get what you want to achieve.

As @Pepster64 has mentioned, the usual way to add a global style sheet is to link to it in the head of every page.
This may of course be done via PHP, either by having the link or the CSS code as an include on toyr pages, or by putting the link into a global page template which all pages use.

That URL returns a 404 error. That has nothing to do with PHP.
It must be a valid URL that may be accessed by the client.

Sam, I have deleted that link already but you got 404 because I wrote there USER and REPO assuming that the user would try to run a similar html-css file via PHP from that user’s own GitHub account.

Anyway:

I just want to run global CSS from index.php directly somehow.
If it’s not possible, please never mind.

It should work if the URL can be accessed by anyone.
It won’t work on a private URL.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.