Altering the code in a PHP include
Posted: Mon Feb 19, 2007 10:40 am
I am having problems... that's wrong. I have an issue I should say, with php and includes that I need to find a solution for and wondered if there was anyone on here that might know of a solution.
Firstly, the back story
I am setting up web pages like this at the moment:
The header and the footer php files include layout information and standard bits for the site, including SEO bits, keywords and the navigation. I wanted to have SEO friendly URLs for some of the pages (the dynamic ones) and so studiously set about writing the .htaccess file only to find out that the host who I have to use not only doesn't allow the use of rewriting on there site.
A quick test later and I discovered that I can do this another way but it throws up a problem. Currently all the images that I have, including the CSS file, are relitave links. I am loathed to have to rewrite them all and so wondered if there was another way of doing it.
And so to the problem:
How can I take a php file and change all of the links within it and then include it on the page that I am creating. I was thinking about using str_replace but that didn't seam to work.
If anybody has any thoughts then I would be more than grateful and I am sure this could be of use to others who may have the same (or similar) issues.
All the best
Steve
Firstly, the back story
I am setting up web pages like this at the moment:
Code: Select all
<?php include("header.php");?>
<div class="about_title">Article Title</div>
<div class="abour_cont">
Article Content
</div>
<?php include("footer.php");?>A quick test later and I discovered that I can do this another way but it throws up a problem. Currently all the images that I have, including the CSS file, are relitave links. I am loathed to have to rewrite them all and so wondered if there was another way of doing it.
And so to the problem:
How can I take a php file and change all of the links within it and then include it on the page that I am creating. I was thinking about using str_replace but that didn't seam to work.
If anybody has any thoughts then I would be more than grateful and I am sure this could be of use to others who may have the same (or similar) issues.
All the best
Steve