You are here: Re: capturing print output of function to variable « PHP Programming Language « IT news, forums, messages
Re: capturing print output of function to variable

Posted by Frank van Meurs on 06/25/06 21:54

Joe Estock wrote:
> Ben Holness wrote:
>> Hi all,
>>
>> I have a function, say:
>>
>> function printTable($Variables)
>> {
>> ?>
>> <table>
>> <tr><td>Your name is</td></tr>
>> <tr><td>
>> <?php
>> print $Name;
>> print "</td></tr></table>";
>> }
>>
>> (Obviously not my exact function, but a simple one to demonstrate my
>> needs... The function I have inherited is much bigger with much mixed php
>> and html like the example)
>>
>> It is currently used to print the same data table on many pages.
>> I have been asked to have the system send this data table by email, so
>> what I want to do is run the function, but send the output of the
>> function
>> to a variable, in the same way that print_r($arr,1) will return the
>> output
>> instead of printing it.
>>
>> Is this possible?
>>
>> Cheers,
>>
>> Ben
>>
>>
> Try output buffering.
>
> ob_start();
>
> callMyNiftyFunction();
>
> $contents = ob_get_contents();
>
> ob_end_clean();

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация