Jump to content

mod_layout and include()


bugscripts

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! :)
Link to comment
https://forums.phpfreaks.com/topic/21210-mod_layout-and-include/
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
Link to comment
https://forums.phpfreaks.com/topic/21210-mod_layout-and-include/#findComment-94316
Share on other sites

Archived

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

×
×
  • Create New...

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.