Reply to Re: capturing print output of function to variable

Your name:

Reply:


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

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>";
> }
>
> 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.

Like this?

function printTable($Variables, $return = false)
{
$tableHtml = "
<table>
<tr><td>Your name is</td></tr>
<tr><td>$Name</td></tr>
</td></tr></table>";

if($return){
return $tableHtml;
} else {
echo $tableHtml;
return;
}
}

[Back to original 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

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