Re: About printing functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



you can use Output Buffering :

<?php
   ob_start();
      badFunctionThatSpitsInsteadOfReturning();
   $sReturned = ob_get_contents();
  ob_end_clean();
?>

2009/1/21 Edmund Hertle <edmund.hertle@xxxxxxxxxxxxxxx>

> 2009/1/21 Jason Pruim <japruim@xxxxxxxxxx>
>
> >
> > On Jan 21, 2009, at 1:33 PM, Thodoris wrote:
> >
> >  Hi gang,
> >>   Lets say that you have a function that prints something to the output
> >> simply like this:
> >>
> >> function print_str() {
> >>   print "blah blah blah";
> >> }
> >>
> >> I was wondering if there is a way to use this output and store it in a
> var
> >> or something without changing the function itself?
> >> And store the "blah blah blah" somewhere for later use?
> >>
> >> I can think of many reasons that someone could use this.
> >>
> >>
> > I know you said without changing the function... but is there any reason
> > that you can't simply add this:
> >
> > <?PHP
> > function print_str() {
> >        $str = "blah blah blah";
> >        print $str;
> > }
> > ?>
>
> well, I think this will not work because $str is only valid in the function
> (local var!)
>



-- 
Torok, Alpar Istvan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux