bugscripts Posted September 18, 2006 Share Posted September 18, 2006 [I am asking this for someone else]Say I want some PHP code executed on all pages in a certain directory.If I add a PHP include() to the top of all pages with mod_layout, and have this in the included file test.php:[code]<?phpecho $_SERVER['PHP_SELF'];?>[/code]On the page test.html (and all other pages, just an example) I get this printed:[quote]/test.php[/quote]I want this printed:[quote]/test.html[/quote]Thanks for any help! :) Quote Link to comment Share on other sites More sharing options...
tomfmason Posted September 19, 2006 Share Posted September 19, 2006 I can think of a couple ways that you can do this. You could ether use preg_replace or an explode function. Here is an example of explode.[code=php:0]$p = $_SERVER['PHP_SELF'];list($page, $ext) = explode(".", $p);echo $page . '.html';[/code]This may not be the most efficent way of doing this but it will work.Hope this helps,Tom Quote Link to comment Share on other sites More sharing options...
bugscripts Posted September 19, 2006 Author Share Posted September 19, 2006 That's not exactly what I meant. I want it to determine the name of the page mod_layout is including it into, but instead it is giving me the name of the script that is supposed to determine it.Sorry if I am not making any sense :) Quote Link to comment Share on other sites More sharing options...
steveclondon Posted September 19, 2006 Share Posted September 19, 2006 Hi,Just use this. Please note that it doesn't work on a windows server only apache. <?phpecho $_SERVER['REQUEST_URI'];?> Quote Link to comment Share on other sites More sharing options...
bugscripts Posted September 19, 2006 Author Share Posted September 19, 2006 That doesn't work, and the other methods of printing the URL that I know of do the same thing.I tested it with a regular include(), and it works as expected. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.