Jump to content

Archived

This topic is now archived and is closed to further replies.

bugscripts

mod_layout and include()

Recommended Posts

[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]<?php
echo $_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! :)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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  :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.