Results 1 to 3 of 3
Thread: detect requesting file and
Mar 5, 2009, 18:26 #1
detect requesting file and
In php is there a function to detect which file requested the current one?
For example I need to include a php file(global.php) in all my webpages(index), but in that file(global) I want the content of the file requesting it(index) to be inserted in the middle of global.php. This is for index being page content, and global being the outer html shell surrounding content(html shell same for every page). At the moment I have global.php split in 2 parts/files and simply requesting global-part1.php, then displaying content then requesting global.part2.php
Also I need the same function for having a unique css file per webpage type(as well as global.css). At the moment in global-part1.php I have
<link rel="stylesheet" type="text/css" href="<?php echo $substyle ?>"/>
Then in index.php I put the location of the unique stylesheet as a variable.
So you can see I need a function in global.php which detects the location of the file requesting it(which index page), to determine what files need to be gotten. Although maybe for the second part(css), it would be better having it as I do now, since dozens of webpages(of the same type) will share the same css file so having the cssfile as a variable in each index would be simpler than having a massive eleborate function in global.
Or maybe there is another method I don't know about? any ideas?
Mar 5, 2009, 18:44 #2
- Join Date
- Dec 2002
- 0 Post(s)
- 0 Thread(s)
If I follow you correctly, you can get the requested file through $_SERVER['PHP_SELF']. there is also $_SERVER['REQUEST_URI']
Then you can just work based off that...
Mar 6, 2009, 08:25 #3
That makes sense. So since I include the file with the function 'self', the requesing file is the file 'self' is performed on. For some reason I was thinking a function would have to be executed before the file was inserted.
So how would I use this to unscatter my global html shell surrounding content?