RE: [PHP] Re: str_replace an include
| From: | Timothy Hitchens \(HiTCHO\) | Date: | Tue, 21 Jan 2003 15:40:33 +0000 |
| Subject: | RE: [PHP] Re: str_replace an include | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-132428@lists.php.net to get a copy of this message | ||
Where are you getting $read from??
That should be $replace = new mainReplace(); // notice the brackets
Timothy Hitchens (HiTCHO)
Open Source Consulting
e-mail: tim@hitcho.com.au
> -----Original Message-----
> From: jesse [mailto:lawrence_jesse@yahoo.ca]
> Sent: Wednesday, 22 January 2003 1:38 AM
> To: php-general@lists.php.net
> 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 template
> scenario.
> >>For
> >> example:
> >>
> >>str_replace("<!--linkTag--!>", include "links.php", $string);
> >>
> >>This obviously doesn't work, but I'm wondering if anybody
> knows of a
> >>good 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
>