Forum Moderators: coopster
I had the enrmous task around a year ago of transforming an 8.000 + page HTML site into dynamic php, in incorporating a new look in the process. To do this, all in keeping the original file heirarchy (sitemap), I stripped everything "structure" from the above files to leave nothing but the content, and this I made into a function:
<?php
function content() {
?>
<p>All the original HTML here </p>
<p>All the original HTML here </p>
<p>All the original HTML here </p>
<?php
}
?>
...then at the bottom of the page I would call the template (that had headers, columns, variables and such) that itself would call the 'content()' function above in the right place.
I use this technique for new content as well. Yet recently I got the offer to put a block text into the content - I could do this by hand, but have devised a 'magic_word' sytem that would search the page for that 'magic_word' (should I put it in) and replace it with the proper ad. The problem is, I can't seem to get any search and replace to work within the above - even after I pass the completed function to a variable! It just prints out, no matter what I do.
Has anyone ever seen anything like this before? I seem to have php'd myself into a corner.
This content will always be outputted because it isn't within PHP tags anymore. You must use output buffering to capture this into a string so that you can do a search on it. See [us3.php.net...]
<?php
}
?>
<?php
function content() {
return <<<___EOF
?>
<p>All the original HTML here </p>
<p>All the original HTML here </p>
<p>All the original HTML here </p>
<?php
___EOF;
}
echo str_replace('p>', 'li>', content());
?>
<?php
$content = <<<HTML_HERE
<p>All the original HTML here </p>
<p>All the original HTML here </p>
<p>All the original HTML here </p>
HTML_HERE;
include ({template}};
?>
...but that would about amount to the same. I haven't a clue why the heredoc is not working though.