Thanks a lot for your help.
Timothy Hitchens ) wrote:
I can't see what else to suggest just quickly. - what about just as a function not a class??Timothy Hitchens (HiTCHO) Open Source Consulting e-mail: [EMAIL PROTECTED]-----Original Message-----
From: jesse [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 22 January 2003 2:12 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: str_replace an include
Timothy Hitchens ) wrote:
$read is the contents of the file that I'm reading. I actually do have $replace = new mainReplace(); in my code, I just forgot the brackets in my last message;)Where are you getting $read from?? That should be $replace = new mainReplace(); // notice the brackets
Timothy Hitchens (HiTCHO) Open Source Consulting e-mail: [EMAIL PROTECTED]-----Original Message-----
From: jesse [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 22 January 2003 1:38 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: str_replace an include
Thanks a lot, I think that will be the trick, but I'm still
having a bit of a problem.
Here's my scenario:
class mainReplace{
function feedLinks(){
ob_start();
include('links.php');
$file = ob_get_contents();
ob_end_clean();
return $file;
}
}
$replace = new mainReplace;
$read = str_replace('<!--feedLinks--!>',
$replace->feedLinks(), $read); print $read;
Unfortunately, this is not printing the results of the file include
where is should have been replaced. If, however, I say:
print $replace->feedLinks()
it prints out the results.
Any suggestions?
Thanks again,
Jesse Lawrence
J Smith wrote:
I'd recommend looking at the output buffering functions. Something like this would probably work... ob_start(); include("links.php"); $file = ob_get_contents(); ob_end_clean(); The result of parsing and executing links.php will be in $file. Do with it what you will. J Jesse wrote:Hello all, I'm trying to replace a tag with an include in a templatescenario.For example: str_replace("<!--linkTag--!>", include "links.php", $string); This obviously doesn't work, but I'm wondering if anybodyknows of agood way to do this. Thanks a bunch, Jesse Lawrence-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php