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 4 2336
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();
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();
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;
}
}
> Try output buffering. ob_start();
callMyNiftyFunction();
$contents = ob_get_contents();
ob_end_clean();
Perfect! Thanks,
Ben This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark Wilson CPU |
last post by:
This must be easy, but I'm missing something...
I want to execute a Perl script, and capture ALL its output into a PHP
variable. Here are my 2 files:
-------------------------------------...
|
by: Mike |
last post by:
I'm trying to capture data that is created by launching a php file,
for example the last 10 posts in a message forum. If last10.php is
called directly in your browser you'll see hyperlinks to the...
|
by: Tim Williams |
last post by:
----- Original Message -----
From: "Tim Williams" <listserver@tdw.net>
> ----- Original Message -----
> From: "Steve Holden" <steve@holdenweb.com>
> Yeah, I did wonder about changing the...
|
by: ebobnar |
last post by:
I'm sure you all have seen how using the src argument in a script tag
is essentially the same as including the body of the script within
your page. For example:
<script type="text/javascript"...
|
by: Fly Girl |
last post by:
Gurus needed! I'm trying to use a Word class object in order to
capture events in Word. Here's what I have, but the event code
appWord_BeforeDocumentSave... doesn't ever fire.
In a Class Module...
|
by: sparks |
last post by:
They have a new data collection station. The people here are using
access 97....
This third party site will only post data back to us when we do this.
...
|
by: Luigi |
last post by:
Hi to all!
I'd like to execute an external program capturing the stdout/stderr
messages at "real-time". I mean that I don't want to wait for the end
of the process. If I write a code like this:...
|
by: Ed Leafe |
last post by:
I've been approached by a local business that has been advised that
they need to start capturing and archiving their instant messaging in
order to comply with Sarbanes-Oxley. The company is largely...
|
by: Buglish |
last post by:
Hi,
Task :
-Capture a HTML table with use of regular expression from a text string buffer(entire document).
–Pass it to another function to create a multi dimension array out of it.
- Pass it...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |