Forum Moderators: coopster
Current situation:
--------------------------------
<?php $string = $_SERVER["QUERY_STRING"];?>
<?php
$old = ".html";
$new = str_replace("html","html?$string",$old);
echo "$new.";
?>
<p><a href="links/links.php?m=link23&myVariable=<?php echo $string?>">Outgoing Link</a></p>
<p><a href="page1.html">Page 1</a></p>
----------------------------------
HTML is being parsed as PHP.
All outgoing links are finishing with “.php” extension and all internal links are finishing with “.html” extension.
For now, we are OK to maintain outgoing links in the fashion as showed above, manually. This means if we add new outgoing link, we will append variable to it manually so it will be a part of HTML code.
But… for internal links, instead of worrying if each has been appended with the “$string”, we would like to use “str_replace” or whatever is suitable to do it on every page load.
The code above does it (second php script), but only to echo it (if we use echo for testing purpose). What we need it to do is to go through the whole HTML body and replace all instances of links finishing with “.html”
Conceptually, we see it as “find all and replace all”.
How do we do that?
Thank you.