Well, that was a very interesting chase while researching this question…
First, it seems that there is no way to do this. (But, I created a work-around!)
The code you posted works fine. But, the file MUST be included inside PHP.
So, <?PHP include...blah blah blah?> is a PHP command. So the include filename is available.
But, a file included in a header as an external file is not available to PHP.
It does seem to exist inside the browser’s session stream somewhere, but, I can’t find it or
how to pull out the name thru PHP.
A really simple fix is to just include all of your CSS filenames INSIDE a PHP include command.
Then, the filename should be accessible.
So a link like:
would be placed into a file by itself and called css1.php or whatever.
Then, when you go to the page, PHP pre-loads the file which is the css link and then you can access
the name of “css1.php” Which you would know is really css/somefilename.css !
Would take a bit of figuring on what they are.
Another way would be to simply use the page image. Load it using CURL into a variable and parse out just the tags for . That would give you a list of all the linked files you have loaded.
Just curious… Why do you need a list of files inside your page that you wrote? Why not just echo them out?
Anyway, good luck…